That may have more of a symptom than the cause.  The other widget I
defined was:

def choice_widget(field,value,labels,required):
        """
        Widget to substitute a pup-up menu with a set of radio buttons
        """
        id=field._tablename+'_'+field.name
        sro = []
        i = 0
        selected = False
        for x in labels:
                if str(value)==str(i):
                        sro.append( OPTION(x,_value=i,_selected="selected") )
                        selected = True
                else:
                        sro.append( OPTION(x,_value=i) )
                i += 1
        set = [x for x in range(len(labels))]
        if not selected:
                sro = [OPTION('', _value=-1)]+sro
                if not required:
                        set = [-1]+set
        kw = {'_class':'integer', '_id':id, '_name':field.name,
                'requires':IS_IN_SET(set, error_message='required 
information!')}
        return SELECT(*sro, **kw)

And here's an example of its use:

db.define_table('tbl', SQLField('field', 'integer', widget=lambda
a,b:choice_widget(a,b,['a','b'],True)))

When I bring up an insertion form (through appadmin or my own
controller), all is well.  But if I try to submit, and there is an
error (as there will be if nothing is changed), the nesting originally
described appears on the page w/ the error message (for a SELECT,
you'd have to view the source to see the nesting).  If I reload the
form, the nesting appears (but the error messages do not).  If I
navigate away from and back to the insertion form, there's no nesting
(and no error message).

Thanks again,
Scott

On May 8, 10:46 am, mdipierro <[email protected]> wrote:
> I cannot reproduce the problem but there is a typo in your code
>
>         "Widget to allow size of textarea to be specified""
>
> should be
>
>         "Widget to allow size of textarea to be specified"
>
> Massimo
>
> On May 8, 9:12 am, Scott Hunter <[email protected]> wrote:
>
>
>
> > Just downloaded v 1.61.4 (Mac), and I'm having a problem w/ widgets.
> > For example:
>
> > def ta_widget(field,value,nr):
> >         "Widget to allow size of textarea to be specified""
> >         return TEXTAREA("xyz", _type="text", _class="text", _rows=nr,
> > _cols=40,
> >                                         _name=field.name, 
> > _id=field._tablename+'_'+field.name)
>
> > ...
> > SQLField('textfield','text',widget=lambda a,b:ta_widget(a,b,1)),
> > ...
>
> > Yields the following HTML, which presents as a text area w/ a copy of
> > the tag included in the content:
>
> > <textarea class="text" cols="40" id="worksheets_heatdist_defects"
> > name="heatdist_defects" rows="1" type="text"><textarea class="text"
> > cols="40" id="worksheets_heatdist_defects" name="heatdist_defects"
> > rows="1" type="text">xyz</textarea></textarea>
>
> > I have a similar problem w/ a widget that yields a SELECT producing
> > one SELECT inside another (which the browser can handle).
>
> > I'd used the ta_widget in earlier versions of web2py (01/09?).
>
> > Thanks for the help,
> > Scott
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to