Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-27-2008, 12:57 PM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Default How do I fill a zend::form select from db?

Hello,

First post here, so not sure if in the right form.
I have a $result from fetchPairs.
$result = $db->fetchPairs($sql);

How do I assign this to the code below?
$assignedTo = new Zend_Form_Element_Select('assignedTo');

nevermind, I found the answer.

$assignedTo = new Zend_Form_Element_Select('assignedTo');
$assignedTo->setLabel('Assigned to')
->setMultiOptions($result)
->setRequired(true)->addValidator('NotEmpty', true);
Thanks
Frank

Last edited by frocco : 03-28-2008 at 01:55 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 06:15 PM
Junior Member
 
Join Date: Apr 2008
Posts: 4
Default

I don't know if this is the best way but...

In my query, the returned column names are the same as the element names in the form.

Then you can just do $Form->populate( $resulting_query_as_an_array);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:55 AM.