Generating a zend form with dynamic data?
Posted
by meder
on Stack Overflow
See other posts from Stack Overflow
or by meder
Published on 2010-06-09T19:53:42Z
Indexed on
2010/06/09
20:52 UTC
Read the original article
Hit count: 163
I need to access my session and based on the session property I need to grab stuff from the database to use as options in my dropdown.
$_SESSION is:
[sess_name] => Array(
[properties] => Array(
1=> Hotel A,
2=> Hotel B
),
[selected] => 1
)
I need to grab Hotel A from selected, and then access all accounts under Hotel A from the database:
id title hotel_id
------------------------------
1 Hotel A Twitter Account 1
2 Hotel B Facebook Account 2
3 Hotel A Facebook Account 1
I need ids 1 and 3 because my hotel_id is 1 in the context of:
$this->addElement( 'select', 'account', array(
'multioptions' => $NEED_IT_HERE
));
Here's my query / session grabbing code:
$cs = new Zend_Session_Namespace( SESS_NAME );
$model = new Model_DbTable_Social;
$s = "
SELECT social_accounts.*
FROM social_accounts
LEFT JOIN social_media_outlets ON social_media_outlets.id = social_accounts.property
WHERE social_accounts.property=".(int)$cs->selectedclient;
I have this code in my form page, but I need to move it into my model now.
© Stack Overflow or respective owner