8

I was wondering if there is another way of making a certain field of a domain to not appear in the views pages of the dynamic scaffolding capability of Grails?

I can execute the generate-all command on the domain and edit the view myself but I was just wondering if there is a way for me to still take advantage of the dynamic scaffolding capability.

I just want to not show the password field on the show and edit views of my user domain.

2
  • 3
    Not to my knowledge. Scaffolding shouldn't really be used beyond learning and quick demos anyway.
    – Gregg
    Jul 27, 2012 at 10:35
  • If masking the value (instead of hiding the field completely) would be enough, there is a solution here: stackoverflow.com/a/40774872/1004651
    – Matthias
    Nov 23, 2016 at 22:13

1 Answer 1

16

I would disagree with Gregg's comment above. Scaffolding is very helpful in reducing unnecessary code.

Add a constraint called display:false to that property in your domain class, i.e,

static constraints { 
   password display: false
}

This will hide the property for you when scaffolding.

Docs: http://www.grails.org/doc/latest/ref/Constraints/Usage.html

2
  • hi @tomas, thanks for the info. I did not know that there is a display option. thanks for that, but I did the manual way of hiding the password field by generating the static code then taking out the password field from the show and list views. I tried applying the display attribute on my domain but it also hid the field on the create view. anyway, thanks again
    – chip
    Jul 28, 2012 at 2:39
  • 1
    you can customize the render editor template after calling grails install-templates to do this based on the view name. But I guess it might be more trouble than what it is worth.
    – Tomas Lin
    Jul 28, 2012 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.