Basically I reverse engineered the HTML generated from web2py and
came with the following solution:
In SQLFORM.factory I have this definition:
Field('*primary_email_choice*', widget=SQLFORM.widgets.radio.widget, 
requires=IS_IN_SET({'Work' : 'Work', '*Home*' : 'Home'})),

So in the HTML id="*primary_email_choiceHome*"  is a combination of 
*primary_email_choice* and one of the values in the set: *Home.*
So I manually composed to HTML to have more control. I have the 
value in primary_email which determines if the radio check box is checked 
or not dynamically when the HTML is rendered. It is much more cleared that 
way and I have a full control on the design:

                                {{ if fields['primary_email'] == "Home": }} 
                                   
                                    <input type="radio" 
name="primary_email_choice" id="*primary_email_choiceHome*" value="Home" 
checked="yes"/>
                                {{ else: }}                    
                                    <input type="radio" 
name="primary_email_choice" id="primary_email_choiceHome" value="Home" />
                                {{ pass }}
                                <label for="primary_email_choiceHome">{{ if 
fields['primary_email'] == "Home": }}Primary Email: Home{{ else: }}Choose 
Email Home as Primary Email{{ pass }}</label>

Radio check-boxes are under-described in the book and I believe this 
solution will help others to do the same.



Reply via email to