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.1 » Empty form->getValues() after validation
Empty form->getValues() after validation [message #61758] Wed, 24 September 2008 16:55 Go to next message
caponica  is currently offline caponica
Messages: 69
Registered: March 2008
Location: London

I'm putting together my first 1.1 forms and have run into a snag... any help would be most appreciated!

The problem is this:

I have defined a form class and can display the form on the page. I can define validators and run them against the form - displaying the correct error messages. All good.

However. Failed (invalid) forms are not populating with the cleaned data from the validator and, furthermore, a call to $this->form->getValues returns an empty array - I was expecting an array of cleaned values.

My code snippets are below - thanks in advance for your help!



  public function executeTest($request)
    $this->form = new TestForm();
    if ($request->isMethod('post')) {
      if ($this->form->isValid()) {
        //do something
//the next two lines are ugly, but provide a quick and dirty debug

class TestForm extends sfForm {
  public function configure() {
      'aField'       => new sfWidgetFormInput(),
      'bField'       => new sfWidgetFormInput(),

      'aField' => new sfValidatorString(array('min_length'=>40)),
      'bField' => new capValidatorName(),

class capValidatorName extends sfValidatorString
  protected function configure($options = array(), $messages = array())
    parent::configure($options, $messages);

   * @see sfValidatorBase
  protected function doClean($value)
    $clean = (string) $value;
    $clean = strtoupper($clean);
    $clean = parent::doClean($clean);
    return $clean;

Re: Empty form->getValues() after validation [message #91548 is a reply to message #61758 ] Fri, 15 January 2010 17:21 Go to previous message
kiewic  is currently offline kiewic
Messages: 6
Registered: December 2008
Junior Member
Hey, I have also that erro, how did you solve it?
Previous Topic:Symfony 1.1 / Doctrine and SfGuard
Next Topic:Installation Process
Goto Forum:

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