Thanks !

On Wed, Jul 28, 2010 at 06:46, mdipierro <mdipie...@cs.depaul.edu> wrote:

> in trunk
>
> On Jul 27, 4:37 am, _po <povaub...@free.fr> wrote:
> > Hi Massimo,
> > I sent you this last week :
> > I hope the patch is still up to date...
> >
> > With this patch, radio widget can use 'cols' attribute ; As previously
> > done for
> > checkboxes.
> >
> > Grettings,
> > PO.
> >
> > diff -r dcd13ab59569 gluon/sqlhtml.py
> > --- a/gluon/sqlhtml.py  Tue Jul 20 02:43:46 2010 -0500
> > +++ b/gluon/sqlhtml.py  Tue Jul 20 10:00:06 2010 +0200
> > @@ -232,10 +232,25 @@
> >              else:
> >                  raise SyntaxError, 'widget cannot determine options
> > of %s' \
> >                      % field
> > -        opts = [TR(INPUT(_type='radio', _name=field.name,
> > +
> > +        options = [(k, v) for k, v in options if str(v)]
> > +        opts = []
> > +        cols = attributes.get('cols',1)
> > +        totals = len(options)
> > +        mods = totals%cols
> > +        rows = totals/cols
> > +        if mods:
> > +            rows += 1
> > +
> > +        for r_index in range(rows):
> > +            tds = []
> > +            for k, v in options[r_index*cols:(r_index+1)*cols]:
> > +                tds.append(TD(INPUT(_type='radio', _name=field.name,
> >                           requires=attr.get('requires',None),
> >                           hideerror=True, _value=k,
> > -                         value=value), v) for (k, v) in options if
> > str(v)]
> > +                         value=value), v))
> > +            opts.append(TR(tds))
> > +
> >          if opts:
> >              opts[-1][0][0]['hideerror'] = False
> >          return TABLE(*opts, **attr)
> > @@ -1199,3 +1214,4 @@
> >          components.append(TBODY(*tbody))
> >
> >  form_factory = SQLFORM.factory # for backward compatibility,
> > deprecated
> > +
> >
> > On 27 juil, 11:15, mdipierro <mdipie...@cs.depaul.edu> wrote:
> >
> > > I thought it was included unless I got confused with a different
> > > patch. Please ask him to resend.
> >
> > > On Jul 27, 3:21 am, Mathieu Clabaut <mathieu.clab...@gmail.com> wrote:
> >
> > > > Hi Massimo,
> >
> > > >  A colleague of mine tell me he sent you a patch to include a
> horizontal
> > > > radio buttons in gluon (similar to the existing horizontal
> checkboxes).
> > > >  Has the patch a chance to make its way to the trunk ?
> >
> > > > Best regards,
> >
> > > > -Mathieu
> >
> > > > On Tue, Jul 27, 2010 at 10:15, Alastair Medford
> > > > <alastairmedf...@gmail.com>wrote:
> >
> > > > > I was wanting to have horizontal radio buttons in my forms, so I
> set
> > > > > about making my own widget. The widget works well, except for one
> odd
> > > > > behavior. When I load the form, the first radio button is selected
> as
> > > > > desired. But after the form submits, page refreshes etc, the last
> > > > > radio buttons in the list are selected. IE, rather than defaulting
> to
> > > > > the first element selected as it did the first time, it defaults to
> > > > > the last. As this form will be submitted many times in a row, and
> the
> > > > > first option is the most often used, this proves to be a bit of a
> > > > > pain. I've tried this in multiple browsers to the same effect, so
> I'm
> > > > > pretty sure it's happening due to how the code is written. But I'm
> not
> > > > > really sure where this behavior is written. Anyone have any ideas?
> >
> > > > > The code for my modified widget is below:
> >
> > > > > class RadioWidget_Horizontal(OptionsWidget):
> >
> > > > >    @staticmethod
> > > > >    def widget(field, value, **attributes):
> > > > >        """
> > > > >        generates an unordered list of radio buttons, which has
> > > > >        a css class radio_list so it can be styled inline.
> >
> > > > >        see also: :meth:`FormWidget.widget`
> > > > >        """
> >
> > > > >        attr = OptionsWidget._attributes(field, {}, **attributes)
> > > > >        attr['_class'] = attr['_class'] + " radio_list"
> >
> > > > >        if hasattr(field.requires, 'options'):
> > > > >            options = field.requires.options()
> > > > >        else:
> > > > >            raise SyntaxError, 'widget cannot determine options of
> %s'
> > > > > % field
> > > > >        opts = [LI(INPUT(_type='radio', _name=field.name,
> > > > >                         requires=attr.get('requires',None),
> > > > >                         hideerror=True, _value=k,
> > > > >                         value=value), v) for (k, v) in options if
> > > > > str(v)]
> > > > >        if opts:
> > > > >            opts[-1][0]['hideerror'] = False
> > > > >            opts[0][0]['_checked'] = "checked"
> > > > >        return UL(*opts, **attr)
>

Reply via email to