Hi,
You can use the sfWidgetFormDoctrineChoice widget with the 'query'
option, thus, you can pass params to your query throught the form option
system :
*In action :*
$this->form = new campaignForm($record, array('organization' =>
$user->organization) // or any param you want from $request object
*In form :*
$query =
Doctrine::getTable('Campaign')->getCampaignsQuery($this->getOption('organization'))
$this->widgetSchema['campaign_id'] = new sfWidgetFormDoctrineChoice(array
(
'model' => 'Campaign',
'query' => $query
));
Hope it help you.
Samuel Morhaim wrote:
I have a question, I have a dropdown that needs to be populated from
the database, but with a query, and the query is based on a post
variable.
I know that sfWidgetFormDoctrineChoice has an option for passing a
method, but I can't pass a method + parameter like that.
So I used the simple sfWidgetFormChoice with the choice value being
the Doctrine getTable and the parameter.. as shown in the bottom of
this email.. HOWEVER, the dropdown is not well populated. The
dropdown is formed like this:
<option value="0">20 Off Code</option>
<option value="1">Special Sale</option>
<option value="2">30 Off</option>
This is incorrect, since the value for 20 Off Code is not 0 , is
actually 1 so the index is wrong.
$this->widgetSchema['campaign_id'] = new sfWidgetFormChoice(array
(
'choices' =>
Doctrine::getTable('Campaign')->getCampaigns(sfContext::getInstance()->getUser()->getGuardUser()->Organization)
));
What can I do ?
Thank you.
--
If you want to report a vulnerability issue on symfony, please send it
to security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en