I created a static scaffolding for my domain class and got a controller for that domain class. The create action of the controller looks like:
def create() {
[userInstance: new User(params)]
}
I wonder why the line:
[userInstance: new User(params)]
has been added. Obviously when the create action is invoked, there wont be any params – so why would this line have been added?
Not necessarily – imagine a situation where you want to pre-populate a couple fields in the form of the create view. You could use:
Which would result in the view’s
userInstancehaving a populated username field for display in the form.