For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > March 2006 > Re: [PEAR] QuickForm Controller default select values









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] QuickForm Controller default select values
Justin Patrin

2006-03-28, 3:59 am

On 3/27/06, Timothy Marsolais <timothy@technology-works.net> wrote:
> Hi Everyone,
>
> I know that we have been discussing this quite a bit lately, but I search=

ed the archives, google,
> etc., and I am still having a problem.
>
> I made a wizard modeled after the state machine example, using Quickform =

controller. It works great,
> processes perfectly, and validates without a hitch. When I try load defa=

ults to create an update
> process, the select elements will not show the default values while all t=

he other fields show the
> defaults just fine. Is there a special trick for getting the select elem=

ents to pick up the Default
> values that I fed the controller object?
>
> I pulled the default values from a database, assigned the data to appropr=

iately named key=3D>value
> pairs in an array ($defaults), and fed the $defaults array to the Control=

ler using the setDefaults()
> method. All of the other fields work like a charm, but the select method=

s turn up with nothing.
>


Are you perhaps trying to set the value to the label of the select
rather than the value?
$form->addElement('select', 'sel', 'Select', array('val' =3D> 'Label'));
$form->setDefaults(array('sel' =3D> 'val'));

--
Justin Patrin
Sponsored Links







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

Copyright 2008 codecomments.com