"$sfRequest = sfContext::getInstance()->getRequest();
if ($productArray = $sfRequest->getParameter('product')) {
$idParent = $productArray['id_parent'];
} else {
$idParent = $sfRequest->getParameter('id_parent');
}
Is there a better way to solve this problem?"
This is bad because your form shouldn't be using sfContext::getINstance().
You should use $options. IMHO.
So yes there is a better way : using options. Deport this code from your
$form->configure() to your action controller, and "inject" the $idParent
using form $options constructor.
This way you'll be able to do $idParent = $this->getOption('id_parent');
So the form will not have the knowledge of "where" to take the info from
(from GET or from POST ?), because it will be the role of the action to take
care of this.
You say you have to dig in the POST'ed params to get the product_id. So,
basically, you have the information. Where's the problem ?
Perhaps you want to make things clear ? Like, in executeNew()' form, adding
a "derived_product_id" hidden widget which contains the ID given by the GET,
so you'll get it in the POST too, in the executeCreate()' form ?
Regards,
Before Printing, Think about Your Environmental Responsibility!
Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!
On Sun, Mar 13, 2011 at 3:49 PM, Illya Klymov <[email protected]>wrote:
> I've played with options - but it seems no difference for me - if i set an
> option for form in executeNew handler, it's not passed to form when
> executeCreate is running. And how could I add an input, which would not be
> affected by my setNameForm of widgetSchema. That mean's i would to like to
> have all product-related fields in POST still in product array, and separate
> field for id_product
>
> --
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en