coma
coma

Reputation: 16639

sfWidgetFormInputText weird behaviour

Well, I have this form:

class CaracteristicaForm extends sfForm {

    public function configure() {

        $this->setWidgets(array(
            'caracteristica' => new sfWidgetFormInputText(array('default'=>'hola mundo'))
        ));

        $this->setValidators(array(
            'caracteristica' => new sfValidatorString(
                array(
                    'max_length' => 150,
                    'required' => true
                )
            )
        ));

        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    }

}

and then I try to...

$form = new CaracteristicaForm();
$this->embedForm('caracteristica', $form);

but the rendered inputText does not have any value at all.

What am I missing?

Ok, to reproduce this you need to embed this form into another form (mine is a Doctrine child form) so maybe is something about some method changing the value?

Well, passing an array defaults did the trick:

$form = new CaracteristicaForm(array('caracteristica' => $caracteristica));

Upvotes: 1

Views: 704

Answers (1)

Darmen Amanbay
Darmen Amanbay

Reputation: 4871

Why not try to

$form->setDefault('caracteristica', $caracteristica);

in action?

Upvotes: 1

Related Questions