Regarding the radio buttons, it is strange that they don't accept a
tuple for desc/value like the Dropdown class does.  For a dropdown,
you can do this:

form.Dropdown('a', [('value1', 'desc1'), ('value2', 'desc2')])

and it detects that they are tuples when it renders.  I'm not sure why
this isn't the case with radios, except possibly that they just aren't
used very frequently.  There probably should be labels on the
descriptions also, as you point out.  Any reason for this Aaron?


Regarding putting each radio on it's own row and doing other more
obscure stuff, I'd say just create a subclass of Radio and override
it's render function: eg...

class MyRadio(form.Radio):
    def render(self):
        x = '<ul style="list-style-type: none;">'
        for arg in self.args:
            if self.value == arg:  select_p = ' checked="checked"'
            else: select_p = ''
            x += '<li><input type="radio" name="%s" value="%s"%s%s />
%s </li>' % (net.websafe(self.name), net.websafe(arg), select_p,
self.addatts(), net.websafe(arg))
        return x+'</ul>'

This is just an example (haven't tested it), but you get the idea.
You can also sublcass the Form class and redo it's render function.

To add tags and fieldsets is possible, but a little more complicated
because the Form class expects each input to have a name and value.
You can fake this, but the form.d feature is no longer just a dict of
the user's input.  I like to do web.insert('mytable', **form.d) once
everything's been validated, so a tags and fieldsets would mess with
this.

Hope this helps,
Justin

On Aug 4, 6:42 am, keizo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to make a radio button similar to:
>
> <label class="option"><input type="radio" name="format" value="1"
> checked="checked"  class="form-radio" /> Filtered HTML</label>
> <label class="option"><input type="radio" name="format" value="2"
> class="form-radio" /> Markdown</label>
>
> I get close by:>>> a=form.Radio('format',[1,2])
> >>> a.render()
>
> '<span><input type="radio" name="format" value="1" id="format" /> 1
> <input type="radio" name="format" value="2" id="format" /> 2 </span>'
>
> But clearly I need to be able to label it something other than the
> value 1 or 2.  Any ideas?
>
> I think this will require some changes to form.py, but then again I
> don't know much of anything.
>
> I also want to put each radio button on it's own row.  Perhaps
> something that looks like this would be good?  ie similar to
> checkboxes.
>
> a = form.Form(
>                   form.Radio('format',value=1,description='Filter
> HTML',checked=True,post='an explanation here'),
>
> form.Radio('format',value=2,description='Markdown',post='more info
> here')
>        )
>
> Anyway, just wanted to see if anyone's run into this before.  See also
> a bug I submitted about 
> checkboxes:https://bugs.launchpad.net/webpy/+bug/128233
>
> Thanks for any assistance.
>
> Keizo
>
> ps.  I have been rewriting my Drupal based site in python/webpy for
> the past few weeks.  Any suggestions for how to go about making it an
> open source project?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to