I am using a noSelection attribute in the <g:select> tag of the Account field for my Load create view. When a user does not make a selection and clicks the “Create” button I expect the current values of all form fields to be passed to the save closure in my Load controller, which in turn re-calls the create view and populates that view with the previously mentioned current values. This does not happen for two of my form fields and I am unclear why.
Here is what the Load create view called by the /truckingmanagement/load/create controller looks like:
If a user does not make a selection on in the Account field and then proceeds to click the “Create” button, a load obviously cannot be created. Here is what the resulting Load create view called by the /truckingmanagement/load/save controller looks like:

So I have two issues here, the first of which is that the Logged By field in the second view is not populated with the value selected in the first view. Also, the drop down box is completely empty, there are no users to select from. The second issue is that the Account field drop down box is completely empty, there are no accounts to select from.
Here are the <g:select> tags used for the Logged By and Account fields in the Load create view.
Logged By field:
<g:select name="loggedBy.id" from="${loggedByUsers}" optionKey="id" value="${loadInstance?.loggedBy?.id}" />
Account field:
<g:select id="account" name="account.id" from="${accountsWithCargoDestinations}" optionKey="id" noSelection="['':'-Select-']" />
Here are the create and save closures in my LoadController:
def create = {
Role role1 = Role.findByAuthority("ROLE_ADMIN")
Role role2 = Role.findByAuthority("ROLE_OFFICE_PROFESSIONAL")
Role role3 = Role.findByAuthority("ROLE_DRIVER")
def loggedByUsers = UserRole.findAllByRoleInList([role1, role2, role3]).user
def loadInstance = new Load()
loadInstance.properties = params
def accountsWithCargoDestinations = Account.findAllByUserInList(Address.findAll("from Address as addresses where addresses.cargoDestination=true").user)
return [loadInstance:loadInstance, loggedByUsers:loggedByUsers, accountsWithCargoDestinations:accountsWithCargoDestinations]
}
def save = {
def loadInstance = new Load(params)
if (loadInstance.save(flush: true)) {
flash.message = "${message(code: 'default.created.message', args: [message(code: 'load.label', default: 'Load'), loadInstance.id])}"
redirect(action: "show", id: loadInstance.id)
}
else {
System.out.println params //Trying to see if any values from the problem fields got lost.
render(view: "create", model: [loadInstance: loadInstance])
}
}
You will notice in the println statement in the else part of my save closure which prints out the params. When I did this I found that the value selected in the Logged By field in the first view was indeed passed from the first view all the way to this point correctly, but I don’t know why it is not displayed when the Load create view is rendered in the very next line of code, or at the least why something (i.e. loggedByUsers from the truckingmanagement/load/create controller) does not populate the Logged By field when the view is rendered. Any help would be appreciated, and sorry for the verbosity.
To answer your question posed in the comment response. You might want to investigate using chain in your controller. You will need to re-work your create action a little to only instance a new loadInstance if not already present in the model. However, that should do the trick.