I've got a Model with a Many-To-Many relationship and have applied the CRUD module to it, so I get a nice multi-select box rendered on the admin screen, but it's only 4 lines high. I want to specify at least 20 lines but because CRUD is all auto-generated by reflecting the object (I guess...), even overriding the template doesn't allow for this.
The code I need to override is in views.tags.crud/relationField.html
- I just want to add a "size" value like this :-
<select id="${field.id}" name="${pName}" multiple="yes" size="20">
but it doesn't seem overridable.
Anyone got any tricks to getting round this?
You can first override the show
and blank
templates for the controller.
Then, declare the form fields explicitly inside the template, like this:
#{crud.form fields: ['field1','field2','field3'] /}
Leave your special case field out of the list. Then, after the form tag, add the necessary HTML for your field in any way you like. (You can look at how the field would be constructed in relationField.html
and only make the necessary changes.)
It's a bit hacky but nevertheless a decent way to achieve what you are after. Hope this helps!
http://www.playframework.org/documentation/1.2.4/guide7#aCustomizingthePostforma
You could use a JQuery script on load to alter the form...