This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » Can't access form request parameters  (5) 1 Vote(s)
Can't access form request parameters [message #72482] Sun, 15 February 2009 09:25 Go to next message
edwin  is currently offline edwin
Messages: 5
Registered: December 2008
Junior Member
I've been futzing with this for the whole day Sad

I'm starting with a fresh module and using the default edit template to make updates. However, inside the executeUpdate action, I can see the form parameters using $request->getPostParameters()

Array ( [sf_method] => put [juucy_user_person_score] => Array ( [score] => 2 [id] => 1 [article_id] => 1 [person_id] => 2 [user_id] => 2 [token] => 7c87e8fe108b881d98d02ffed765684c00dafeec [_csrf_token] => 6afbcc78f4f8ad2c54aead5e823658bf ) )

The weird thing is that $request->getParameter('id') returns a value. However I can't access any parameters using $request->getParameter(PARAMETER_NAME).


My form is setup as follows:

    $this->setWidgets(array(
      'id'         => new sfWidgetFormInputHidden(),
      'article_id' => new sfWidgetFormInputHidden(),
      'person_id'  => new sfWidgetFormInputHidden(),
      'user_id'    => new sfWidgetFormInputHidden(),
      'score'      => new sfWidgetFormChoice(array('choices'=>$score_types, 'multiple'=>false, 'expanded'=>false)),
      'created_at' => new sfWidgetFormDateTime(),
      'updated_at' => new sfWidgetFormDateTime(),
      'token'      => new sfWidgetFormInput(),
    ));

    $this->setValidators(array(
      'id'         => new sfValidatorPropelChoice(array('model' => 'JuucyUserPersonScore', 'column' => 'id', 'required' => false)),
      'article_id' => new sfValidatorPropelChoice(array('model' => 'JuucyArticle', 'column' => 'id')),
      'person_id'  => new sfValidatorPropelChoice(array('model' => 'JuucyPerson', 'column' => 'id')),
      'user_id'    => new sfValidatorPropelChoice(array('model' => 'sfGuardUser', 'column' => 'id')),
      'score'      => new sfValidatorInteger(),
      'created_at' => new sfValidatorDateTime(array('required' => false)),
      'updated_at' => new sfValidatorDateTime(array('required' => false)),
      'token'      => new sfValidatorString(array('max_length' => 255)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'JuucyUserPersonScore', 'column' => array('token'))),
        new sfValidatorPropelUnique(array('model' => 'JuucyUserPersonScore', 'column' => array('article_id', 'person_id', 'user_id'))),
      ))
    );


Re: Can't access form request parameters [message #72503 is a reply to message #72482 ] Sun, 15 February 2009 14:55 Go to previous messageGo to next message
tom.lis.  is currently offline tom.lis.
Messages: 78
Registered: January 2009
Location: Lublin
Member
Hi,
try :
$request->getParameter(form_name[PARAMETER_NAME])

or bind the form before accessing parameters and use
$form->getValue (PARAMETER_NAME);
Re: Can't access form request parameters [message #95281 is a reply to message #72503 ] Thu, 11 March 2010 15:23 Go to previous messageGo to next message
Bitcoder  is currently offline Bitcoder
Messages: 15
Registered: December 2009
Location: Quito
Junior Member
Hi! I am having same problem but I try to access from "create action" to request parameters. I used $request->getParameter(form_name[PARAMETER_NAME])

how Tom suggested but no results. Resulting form send me null values. Where is the trick to access form_name[PARAMETER_NAME] style variables?

Regards


Guillermo Garcia
Re: Can't access form request parameters [message #95323 is a reply to message #72482 ] Fri, 12 March 2010 07:18 Go to previous messageGo to next message
Levelx  is currently offline Levelx
Messages: 358
Registered: April 2009
Location: Germany
Faithful Member
Quote:

The following behaviors are deprecated in symfony 1.3, and will be removed in symfony 1.4:

* The sfParameterHolder::get(), sfParameterHolder::has(), sfParameterHolder::remove(), sfNamespacedParameterHolder::get(), sfNamespacedParameterHolder::has(), and sfNamespacedParameterHolder::remove() methods support for the array notation ([]) is deprecated and won't be available in symfony 1.4 (better for performance).



Just in the case you use symfony 1.4 you have to do it in 2 steps if I remember right what I had to do when moving to 1.4.
$myParaArray = $request->getParameter(form_name);
$myPara = $myParaArray['PARAMETER_NAME'];
Re: Can't access form request parameters [message #98224 is a reply to message #95323 ] Wed, 28 April 2010 18:15 Go to previous message
tofuwarrior  is currently offline tofuwarrior
Messages: 16
Registered: December 2009
Location: Cardiff
Junior Member
Thanks for that dude.

I've been tearing my hair out for about 2 hours.
I'm on 1.4.


Before you criticise someone, walk a mile in their shoes. That way you will be a mile away and have their shoes.
Previous Topic:Problem with the new form system (form in form and ajax)
Next Topic:can the request from a form be sent to the action of components?
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software