Required field label

37 views
Skip to first unread message

Tu Duong

unread,
Jun 19, 2018, 1:54:31 PM6/19/18
to web2py-users
Hi, what is the best way to add red * (or any indication that the field is required for user) in the label of the required field? Thanks

sandeep patel

unread,
Jun 22, 2018, 7:01:19 AM6/22/18
to web...@googlegroups.com
If yor are using SQLFROM than You can try this 
labels={'field_name':P('name',B('*',_style:'color:red'))}

Best

On Tue, Jun 19, 2018 at 11:24 PM Tu Duong <tduo...@gmail.com> wrote:
Hi, what is the best way to add red * (or any indication that the field is required for user) in the label of the required field? Thanks

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Glaros

unread,
Jun 22, 2018, 10:30:33 AM6/22/18
to web2py-users
Sandeep:

(1) what does the "P" and "B" stand for?   

(2) is there a related way to change font size for individual field names?

In the above example, I think the style statement needs an equal sign instead of colon:

    form_add_new_role_member_status = SQLFORM.factory(db.role_member_status_instance, labels={'role_member_status_fk':P('Role Member Status', B('*',_style='color:Red;font-size:140%'))}) 

thanks

Alex Glaros

Anthony

unread,
Jun 22, 2018, 10:48:23 AM6/22/18
to web2py-users
On Friday, June 22, 2018 at 10:30:33 AM UTC-4, Alex Glaros wrote:
Sandeep:

(1) what does the "P" and "B" stand for?

They are web2py HTML helpers for the <p> and <b> tags.
 

(2) is there a related way to change font size for individual field names?

The best approach is to add an HTML class to the label and use a CSS rule.
 
Anthony
Reply all
Reply to author
Forward
0 new messages