Re: FormBuilder and SubForms with reverseLinks?
| From: | Justin Patrin | Date: | Tue, 01 Nov 2005 04:38:25 +0000 |
| Subject: | Re: FormBuilder and SubForms with reverseLinks? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21723@lists.php.net to get a copy of this message | ||
On 10/31/05, Brett Bieber <brett.bieber@gmail.com> wrote:
> DB_DataObject_FormBuilder and SubForms -
> Is there an easy way to automatically create subForms for tables that
> reverseLink back to the main table?
>
> The example in the documentation refers to a table for [gender] and a table
> for [people]. The table [people] holds the gender_id for a record in the
> [gender] database. This allows you to show a list of people linked to that
> [gender].gender_id when you use fb to build a form for [gender] and are
> editing a record.
>
> I'd like to see reverseLinks taken a step further by generating subForms for
> the reverseLinks. The gender example doesn't suit this well because the
> people table would obviously be larger than gender --- so lets say we have
> the table [people] and a table [cars] to store the cars that people own.
> This is a 1-n, one to many, relationship with people->cars.
>
> We can manually add in a subForm element for the cars - but would it be
> possible for formbuilder to do this automatically? The
> database.links.iniknows which field holds the foreign key (something
> like [cars] people_id =
> people:people_id in this case), and formbuilder would just have to create a
> new formbuilder element and add a subform for each car by the foreign key....
> (and also invoke the processForm for each generated subForm).
>
> Is this possible with FormBuilder, and would others find this as a useful
> feature? Or should we just continue handling all of this manually for each
> instance where I have a reverse linked record?
>
> JustinP, I'm informally posing this question to you, as I'm sure you've come
> across this before.
>
Sounds like an interesting and useful idea. Yes, it's fully possible
with FormBuilder as it is now and shouldn't be too hard to make it
work. It would need to be an option, though, as this kind of feature
creates quite a bit of overhead and shouldn't be assumed to be wanted.
(Of course, I know of no-one but you using reverseLinks anyway ;-)
I don't have a lot of time myself to add this, but if you'd like to
take a stab at it I could help you with pointers. I would suggest
looking at linkNewValue for how to create, store, and process
formbuilder, form, and subform objects.
--
Justin Patrin