Re: FormBuilder : crosslinks question

From: Date: Wed, 20 Jul 2005 20:41:54 +0000
Subject: Re: FormBuilder : crosslinks question
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20076@lists.php.net to get a copy of this message
On 7/20/05, Thomas Balthazar <tba@voxteneo.com> wrote: > Hi everybody, > > Here is my problem : > > 1/ I have a m:n relationship between DOCUMENTS, COUNTRY. > So I have 3 tables DOCUMENTS, JOIN, COUNTRY. > > 2/ In COUNTRY, I have a flag saying if a country is in the EU or not. > > 3/ I have set up FormBuilder to display a multi-select filled in with > the countries in the DOCUMENTS form. Ok, simple. > > 4/ I can filter the COUNTRIES with the prepareLinkedDataObject function, > so that only COUNTRIES from the EU are displayed. > > 5/ For some reasons, what I want to do is to display 2 multi-select : > - one with the COUNTRIES inside EU > - one with the COUNTRIES outside EU > > And I really cannot figure out how to do that. > This would be kind of a split of one element into two. There's not really any way to do this with FormBuilder at the moment. If you had seperate columns in the JOIN table for EU and non-EU countries I could help you hack it, but that's not a good solution for this problem. You could fix this in one of many ways (as usual). I suggest that you add an element in postGenerateForm (remember you can use HTML_QuickForm::insertElementBefore() to put it where you want it). Make this element the one with the non-EU countries and use DB_DataObject_FormBuilder::getDataObjectString() to get the display string for each country. Name it something special which won't collide with your other elements. Then in preProcessForm take the values from your new select andmerge them with the EU one that FormBuilder created. (use + instead of array_merge as array_merge breaks numeric keys...and PHP treats string keys with #'s as #'s....argh). If you need more help just ask. :-) -- Justin Patrin

« previous php.pear.general (#20076) next »