Thanks, Massimo, Your first hint worked perfectly, however making it hidden didn't work. Any other possibility for that? Cheers, Julio Monteiro mdipierro wrote: My mistake: {{db.delivery.student_id.default=self.id}}You can make it hidden (I think) with {{db.delivery.student_id.readable=db.delivery.student_id.writable=False}} On Sep 8, 9:45 am, Julio Monteiro <jmonte...@gmail.com> wrote:Hello Massimo, On doing that I get the following error in that line:{{db.delivery.student_id=self.id}}SyntaxError:Object exists andcannot be redefined:student_id However, if I do:{{db.delivery.student_id.requires=IS_IN_SET([self.id])}}I get a dropdown to choose student Id, with only the passed id selectable. This would be fine if I could have this field as hidden, is it possible to make it a hidden field in the form? Thanks a lot, Julio mdipierro wrote:Mind that T3 is quite dated. Try replace {{=self.read(db.student)}} {{=self.itemize(db.delivery)}} {{=self.create(db.delivery)}} with {{=self.read(db.student)}} {{=self.itemize(db.delivery)}} {{db.delivery.student_id=self.id}} {{=self.create(db.delivery)}} Let us know if this fixes it. Massimo On Sep 7, 11:42 pm, Júlio Monteiro<jmonte...@gmail.com>wrote:Hello there, On building my first web2py app, I bumped into a problem, perhaps you can help? I have the following DB: db.define_table("student", db.Field("name", length=100, notnull=True), db.Field("type", requires=IS_IN_SET(("Master","Doctorate"))), db.Field("entry_date", "date"), db.Field("deposit_date", "date", notnull=False), db.Field("defense_date", "date", notnull=False) ) db.define_table("delivery", db.Field("category", "string"), db.Field("description"), db.Field("del iver_date", "date", required=False), db.Field("devolution_date", "date", required=False), db.Field("student_id", db.student) ) db.delivery.student_id.requires=IS_IN_DB(db,'student.id','student.name') ----------------- What I want is to have view where I can display student information, while, at the same time, show deliveries related to him and have a create form to add new deliveries, with student_id pre-selected to his id I am using the T3 wiki, so I tried adding the following to a page: {{=self.read(db.student)}} {{=self.itemize(db.delivery)}} {{=self.create(db.delivery)}} If I pass the student id to request.args[0], the read form works allright, but the create form does not set its student_id to the id that came from the request. Is there a way to pass this student_id to the form "initial data" to accomplish that? Or the only way is writing a new widget? Thanks, Julio Monteiro --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@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:30374] initial data to CRUD forms JĂșlio Monteiro
- [web2py:30375] Re: initial data to CRUD forms mdipierro
- [web2py:30405] Re: initial data to CRUD forms Julio Monteiro
- [web2py:30410] Re: initial data to CRUD forms mdipierro
- [web2py:30414] Re: initial data to CRUD f... Julio Monteiro
- [web2py:30416] Re: initial data to C... mdipierro
- [web2py:30418] Re: initial data ... Julio Monteiro