[2.0] Add disable-state (twitter bootstrap 2.x) in form

398 views
Skip to first unread message

Magnus

unread,
Sep 17, 2012, 4:20:53 AM9/17/12
to play-fr...@googlegroups.com
How do we add the "disabled"-state in twitter bootstrap
(http://twitter.github.com/bootstrap/base-css.html#forms)
using my own field constructor
?

See Twitter bootstrap's example:
<input class="input-xlarge" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>

We've tried adding
@ inputText(loginForm("email"), 'disabled -> "blablabla")
but then the field "email" will be null when binding it:
Form<Test> form = loginForm(Test.class).bindFromRequest();
String email = form.get().email; // is null

Thankful for any advise,
Magnus


biesior

unread,
Sep 17, 2012, 5:04:39 AM9/17/12
to play-fr...@googlegroups.com
Use readonly instead, check the key differences between both: http://kreotekdev.wordpress.com/2007/11/08/disabled-vs-readonly-form-fields/

As readonly fields are focusable it's important to mark somehow that they cannot be changed, so your clients won't be confused.

Magnus

unread,
Sep 17, 2012, 10:36:11 AM9/17/12
to play-fr...@googlegroups.com
Ok, yes. Thanks!

Brian Smith

unread,
Sep 17, 2012, 11:11:12 AM9/17/12
to play-fr...@googlegroups.com
Note you should use 'readonly -> "readonly" for valid html5 (ditto disabled).  

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/KqTtz8Lu-rUJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Reply all
Reply to author
Forward
0 new messages