For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > August 2004 > Re: [PEAR] FormBuilder -- add header options to auto-linked select menus









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] FormBuilder -- add header options to auto-linked select menus
Justin Patrin

2004-08-18, 8:57 pm

On Wed, 18 Aug 2004 12:58:05 -0500, Sarah Gray <sarah@fabled.net> wrote:
> Hi --
>
> I think this is simple but I'm not sure how to do it.
> When you make a linked field in a formBuilder
> form through the database.links.ini file,
>
> eg,
> [mc_SPs]
> ethnicity_id = mc_val_Ethnicities:ethnicity_id
>
> how do you add options to this field (eg a header option
> like "Select Ethnicity").
>
> I know how to add options when just using quickform --
>
> $quickForm =& new HTML_QuickForm_select($selectNameField,
> $selMenuInfo['LABEL']);
> $quickForm->addOption( $selMenuInfo['HEADER_TEXT'], '');
>
> --
>
> but not on these auto-linked fields.
>
> Can someone post an example or explanation?
>


Use something like this in your DataObject class:
function postGenerateForm(&$form) {
$sel =& $form->getElement('selectElementName');
$sel->addOption(...);
}

--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--
Justin Patrin

2004-08-18, 8:57 pm

On Wed, 18 Aug 2004 23:44:24 +0200, Norbert Mocsnik
<pear-general@mocsnik.hu> wrote:
> Justin Patrin wrote:
>
> Afaik this will add the option to the end of the list.
> This is why I implemented fb_selectAddEmpty in
> FormBuilder (was it me?) .. that could be improved
> in a future version so it can add arbitrary text as the
> first option to the list.
>


True. If QF doesn't support adding options to the top of the select
box, perhaps this could be added. Shouldn't be too hard.

This is kind of like my moving elements patch that Bertrand refuses to
apply even though is *works perfectly*!

--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--
Sarah Gray

2004-08-25, 8:56 pm



Justin Patrin wrote:

> On Wed, 18 Aug 2004 23:44:24 +0200, Norbert Mocsnik
> <pear-general@mocsnik.hu> wrote:

Thanks for writing. I re-checked my result and see that It *does* add the
option to the end of the list, which I hadn't realized because even though

it is the last element it still comes up as the top
option in my dropdowns, which is what I was looking for. (ie, when you
look at the elements in the list, "Select A Country" is listed under
"Zimbabwe", but when the page loads the dropdown says, as it should,
"Select A Country". I'm not sure why this is, but it is.
[color=darkred]
> True. If QF doesn't support adding options to the top of the select
> box, perhaps this could be added. Shouldn't be too hard.
>
> This is kind of like my moving elements patch that Bertrand refuses to
> apply even though is *works perfectly*!


It does work perfectly. I love it. It should be added ;)

s.

>
>
> --
> DB_DataObject_FormBuilder - The database at your fingertips
> http://pear.php.net/package/DB_DataObject_FormBuilder
>
> paperCrane --Justin Patrin--
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com