On Apr 23, 4:19 am, Joe Barnhart <[email protected]> wrote:
> I found out a bit more regarding the problem. It seems that there is
> an ajax field validator running which requires the input be suitable
> for a "double" variable. The SQLFORM sets the "class" attribute of
> the field to "double" because that is the underlying data type.
>
> Even though my special validator is able to take strings and render
> them into a double, it never gets the chance because the ajax layer is
> rejecting all characters other than [0-9] and [.]. I need to override
> the "class" attribute on this particular field when rendered by
> SQLFORM.
It is not an ajax "validator", it is jQuery code introduced by
web2py_ajax.html using $('input.double').attr('onkeyup', ... ).
Which is why you need to change the class, as you said, to prevent
jQuery from modifying your field. The easiest way is using a widget,
before calling SQLFORM:
db.your_table.your_double.widget= lambda field, value:
INPUT(_type='text',
_id='%s_%s' %(field._tablename, field.name),
_class='mydouble',
_name=field.name,
value='' if not value else str(value),
requires=field.requires)
>
> In the meantime, I am using a manually-created FORM to get by.
>
> -- Joe B.
>
> On Apr 22, 10:49 pm, Álvaro Justen [Turicas] <[email protected]>
> wrote:
>
> > --
> > Álvaro Justen
> > Peta5 - Telecomunicações e Software Livre
> > 21 3021-6001 / 9898-0141
> > http://www.peta5.com.br/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---