Re: DataObject FormBuilder and crosslinks
| From: | Justin Patrin | Date: | Mon, 08 Aug 2005 03:39:27 +0000 |
| Subject: | Re: DataObject FormBuilder and crosslinks | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20319@lists.php.net to get a copy of this message | ||
On 8/7/05, Troy <troy@optcom.net.au> wrote:
> Hi all,
>
> I am a bit confused at the moment trying to solve a problem using
> FormBuilder but not sure if I am on the right track. Basically I have
> the following simple database structure:
>
> ITEMS table
> - item_id
> - cat_id
> - subcat_id
>
> CATEGORIES table
> - cat_id
> - name
>
> SUBCATEGORIES table
> - subcat_id
> - name
>
> CAT_RELATIONS table
> - cat_id
> - subcat_id
>
>
> I have the following in database.links.ini:
>
> [items]
> cat_id = categories:cat_id
> subcat_id = subcategories:subcat_id
>
> [cat_relations]
> cat_id = categories:cat_id
> subcat_id = subcategories:subcat_id
>
>
> I'm using FB to generate a form to create new 'item' entries, and I
> wish to have 2 select boxes, one for category, and one for
> subcategory. The catch is I only want the subcategories for the
> currently selected category to be displayed in the second select box.
> When a different main category is selected, the select box for
> subcategory updates automatically. This will probably involve some
> javascript or a page reload I guess.
>
> I have messed around with crosslinks for the past few hours and
> decided that I can't make them do what I want, and after another hour
> googling, I thought I would ask if it is even possible.
>
> I can think of a couple of kludgey ways that might work, but as
> always I am hoping there is an elegant way to handle this kind of
> scenario with FB?
>
FB is currently not set up to deal with this kind of thing. Crosslinks
are for populating, say, the cat_relations table. What you're asking
about are simple links. Formbuilder *is* set up to handle these, but
it's not set up to handle hier-selects (this is what the kind of
select you want is called). It could possibly be set up for it but it
hasn't yet. I would suggest for now use the preDefElements option and
the preProcessForm callback to create your own hierselect element.
--
Justin Patrin