> In my model I also have a widget which reads like:
>
> db.event.plaats.widget=lambda self,value:INPUT
> (_type='text',_id='place',_class='ac_input',_name='plaats',value=str
> (value),requires=self.requires)
>
> The widget Chris provided me with reads like:
>
> def timeplain(field,value):
>     if value == None:
>         value = ''
>     id = '%s_%s' % (field._tablename, field.name)
>     return INPUT
> (_type='text',_id=id,_class='time_plain',_name=field.name,value=str
> (value),requires=field.requires)
>
> ... and is set in the table definition:
>
> db.Field('tijd',type='time',default='',notnull=True,widget=timeplain)
>
> ... whereas the other widget is set in the validator, don't I have to
> set Chris' widget in a validator too? Furthermore, Chris' widget
> doesn't use  'lambda self,value:' , why not?

"lambda" is a shortcut way of defining a function with no name. The
example I copied happened to give the widget function a name. My
example was based on http://www.web2py.com/AlterEgo/default/show/170 -
check there to make sure what you've got is right.

putting widget=timeplain in the field definition is equivalent to
doing
db.timetable.time.widget = timeplain
outside the table definition.

It's a matter of readability as to which you prefer. Using the lambda
function to create the widget would be slightly less efficient if
there was more than one field that you wanted to use that widget,
because you'd need to define the lamda twice.

>
> Furthermore, when I enter a time in the time field both 10:00 and
> 10:00:00 pass validation. When I enter 1000 or 100000 an error message
> is displayed: must be HH:MM:SS! How do I change this message to read
> like: must be HH:MM! The time references the time at which a program
> starts, so seconds are not relevant.

You can change the error message by using changing the validator
assigment to something like IS_TIME(error_message=T('must be
HH:MM!'))
This is on manual page 178.  The T() is for translation.

> Finally, in one my views I have:
>
> {{=db.event.from_date.formatter(event.from_date)}}
>
> Is there something equivalent to get the time formatted correctly. i.e
> 10:00 instead of 10:00:00

I hope I explained this in my previous post, which crossed over with
you recent reply.

Chris
--~--~---------~--~----~------------~-------~--~----~
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