I'm trying to get an icon in a submit button using GRAILS. I had resolved getting the button to display, but at the expense of the form throwing errors. To display the tags I did a button tag, but then the form throws this error:
--> sessionFactory.currentSession.flush() -->AbstractInstanceController.groovy
Cannot insert NULL into ("APP"."INSTANCE"."STATUS")
--> def instance = super.save(specificInstance, 'specificInstance.label') -->specificInstanceController.groovy
And the button in the gsp:
<button type="submit" name="_action_save" class="btn" value="Save">
<i class="icon-folder-open"></i> Save
</button>
Does anyone know of a way to add an icon to an:
<input type="submit" ...>
or a way of fixing the grails errors being thrown using the
<button>
method?
UPDATE
<g:form name="form">
<g:hiddenField name="status" />
<g:hiddenField name="locationID" value="${instance?.location?.id}" />
<div class="formButtons">
<g:actionSubmit value="Save" name="save_button" class="button cancel" action="save" data-icon="check" />
<input type="submit" name="_action_save" value="Save" class="button cancel" action="save"/>
</div>
<g:render template="form"/>
... "form" has many, many fields in the form of:
<label for="section">Section</label>
<g:textField name="section" class="textfield required" value="${instance?.section}"/>
Controller logic is the default save() scaffold with very few modifications:
@Secured(['IS_AUTHENTICATED_FULLY'])
def save = {
def instance = new Instance(params)
instance.setDescription("instancePE")
if(instance.instanceEnd == null){
flash.message = "${message(code: 'instance.time.null.message', args: [instance.mode.instanceHours])}"
render(view: "create", model: [instance: instance])
return
}
if (!validStartEnd(instance)) {
flash.message = "${message(code: 'instance.invalidRange.message', args: [instance.mode.instanceHours])}"
render(view: "create", model: [instance: instance])
return
}
instance.activeInstanceArchive =
g.render(template: "/templates/showInstances",model:
[loc: instance.instLocation])
def inst = super.save(instance, 'instance.label')
render(view: "create", model: [instance: inst])
}
Domain object is large, but does not have anything unusual about it. It simply lists the objects to store.