[web2py] Re: crud update with represent

2010-04-03 Thread mdipierro
No.
On Apr 3, 10:49 am, Avik Basu  wrote:
> Thanks, that works great.  I have an additional question:  Is there a
> represent argument for in define_table which would allow for a
> formatting of an entire row, based on the fields which were selected
> in the query of crud.select(...)?
>
> Avik
>
> On Apr 2, 8:36 pm, mdipierro  wrote:
>
> > You just need to specify the format. It will make for you both
> > validator and represent attribute.
>
> > #model
> > db.define_table("food",
> >     Field("desc", "string"),
> >     format='%(desc)s'
> > )
>
> > db.define_table("ate",
> >     Field("food_id", db.food)
> > )
>
> > #controller
> > form=crud.update(db.ate,ate_id)
>
> > On Apr 1, 2:22 pm, Avik Basu  wrote:
>
> > > Hi,
> > > As I understand, when crud.update(...) creates a form it pulls the
> > > values of a given record into the form as a string.  If the field is a
> > > reference to another table, then this shows up as a number.  I would
> > > like to instead show the name of the record instead of the id. I have
> > > a represent function set in the data model, but that is only used on
> > > crud.select().
>
> > > So, my question is how can I get the crud.update(...) form to render
> > > the record values with according to the represent function specified
> > > by the represent function of the field.  Code below:
>
> > > #model
> > > db.define_table("food",
> > >     Field("desc", "string",)
> > > )
>
> > > db.define_table("ate",
> > >     Field("food_id", db.food,
> > >         represent=lambda x: db(db.food.id==x).select().first().desc
> > >     )
> > > )
>
> > > #controller
> > > form=crud.update(db.ate,ate_id)
>
> > > Thanks,
> > > Avik

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud update with represent

2010-04-03 Thread Avik Basu
Thanks, that works great.  I have an additional question:  Is there a
represent argument for in define_table which would allow for a
formatting of an entire row, based on the fields which were selected
in the query of crud.select(...)?

Avik

On Apr 2, 8:36 pm, mdipierro  wrote:
> You just need to specify the format. It will make for you both
> validator and represent attribute.
>
> #model
> db.define_table("food",
>     Field("desc", "string"),
>     format='%(desc)s'
> )
>
> db.define_table("ate",
>     Field("food_id", db.food)
> )
>
> #controller
> form=crud.update(db.ate,ate_id)
>
> On Apr 1, 2:22 pm, Avik Basu  wrote:
>
>
>
> > Hi,
> > As I understand, when crud.update(...) creates a form it pulls the
> > values of a given record into the form as a string.  If the field is a
> > reference to another table, then this shows up as a number.  I would
> > like to instead show the name of the record instead of the id. I have
> > a represent function set in the data model, but that is only used on
> > crud.select().
>
> > So, my question is how can I get the crud.update(...) form to render
> > the record values with according to the represent function specified
> > by the represent function of the field.  Code below:
>
> > #model
> > db.define_table("food",
> >     Field("desc", "string",)
> > )
>
> > db.define_table("ate",
> >     Field("food_id", db.food,
> >         represent=lambda x: db(db.food.id==x).select().first().desc
> >     )
> > )
>
> > #controller
> > form=crud.update(db.ate,ate_id)
>
> > Thanks,
> > Avik

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: crud update with represent

2010-04-02 Thread mdipierro
You just need to specify the format. It will make for you both
validator and represent attribute.

#model
db.define_table("food",
Field("desc", "string"),
format='%(desc)s'
)

db.define_table("ate",
Field("food_id", db.food)
)

#controller
form=crud.update(db.ate,ate_id)

On Apr 1, 2:22 pm, Avik Basu  wrote:
> Hi,
> As I understand, when crud.update(...) creates a form it pulls the
> values of a given record into the form as a string.  If the field is a
> reference to another table, then this shows up as a number.  I would
> like to instead show the name of the record instead of the id. I have
> a represent function set in the data model, but that is only used on
> crud.select().
>
> So, my question is how can I get the crud.update(...) form to render
> the record values with according to the represent function specified
> by the represent function of the field.  Code below:
>
> #model
> db.define_table("food",
>     Field("desc", "string",)
> )
>
> db.define_table("ate",
>     Field("food_id", db.food,
>         represent=lambda x: db(db.food.id==x).select().first().desc
>     )
> )
>
> #controller
> form=crud.update(db.ate,ate_id)
>
> Thanks,
> Avik

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.