Empty value of the play field selection field

How to add the parameter "none" in the selection box of the playback frame?

So far I have this:

<select size="1" name="object.id"> <option value="">&{'crud.none'}</option> #{list items:someItems, as:'item'} <option value="${item.id}">${item.name}</option> #{/list} </select> 

but when I select "none", play creates a new object and tries to save the parent object with a link to the newly created object, resulting in a hibernate org.hibernate.TransientObjectException

Any ideas?

+4
source share
1 answer

Set the value of the parameter none to 0 and in your controller add the relation only if (item.id > 0)

 <option value="0">&{'crud.none'}</option> 

What else, if this value is required, you can use a simple JavaScript check to make sure that the user has selected some option

+3
source

All Articles