Thanks Niphlod, this is working. For the record:

def get_bootstrap_radio(options):
    '''<div class="btn-group" data-toggle="buttons-radio">
           <button class="btn" type="button">1</button>
           <button class="btn" type="button">2</button>
           <button class="btn" type="button">3</button>
       </div>'''
    i = []

    for value in options:
        i.append(BUTTON(value, _type="button", _class="btn"))
    return DIV(*i, _class='btn-group', **{'_data-toggle': "buttons-radio" })



On Tuesday, November 20, 2012 9:50:48 AM UTC+1, Niphlod wrote:
>
> this is beginning to be a FAQ
>
> http://web2py.com/books/default/chapter/29/05?search=data-
>
> On Tuesday, November 20, 2012 9:37:34 AM UTC+1, Daniel Gonzalez wrote:
>>
>> Hi,
>>
>> I am trying to create a radio component in a custom web2py form, using 
>> twitter bootstrap styles, as explained 
>> here<http://twitter.github.com/bootstrap/javascript.html#buttons>
>> .
>> In order for the button group to behave like a radio button, we need to 
>> specify the 'data-toggle="buttons-radio"' modifier.
>> I have tried to do this in web2py with '_data_toggle="buttons-radio"', 
>> but web2py is generating data_toggle instead of data-toggle (underscore 
>> instead of minus).
>> Is there a way to tell web2py to convert the underscores in the parameter 
>> names to minus instead of underscore?
>>
>> This is my code:
>>
>> def get_bootstrap_radio(options):
>>     '''<div class="btn-group" data-toggle="buttons-radio">
>>            <button class="btn" type="button">1</button>
>>            <button class="btn" type="button">2</button>
>>            <button class="btn" type="button">3</button>
>>        </div>'''
>>     i = []
>>     for value in options:
>>          i.append(BUTTON(value, _type="button", _class="btn"))
>>     return DIV(*i, _class='btn-group', _data_toggle="buttons-radio")
>>
>> Thanks,
>> Daniel
>>
>

-- 



Reply via email to