2

I am using Symfony 1.3.x for a project.

In the configure() method of one of my forms, I have the following code:

'terms' => new sfWidgetFormInputCheckbox(array('value_attribute_value'=>'terms', 'default' => false )),

The idea is to present the user with a checkbox (default unchecked), which the user will have to check before the form validates.

The problem is that when I display the form, the checkbox is ALWAYS already checked (i.e. selected) - which defeats the purpose of enforcing user confirmation with a checkbox.

Does anyone know how to resolve this?

3 Answers 3

3

Default form values in Symfony essentially have an undocumented hierarchy. It is (higher numbers have higher precedence):

  1. The default value of the widget.
  2. If the form is for a new record, the value of the record.
  3. The form level default for the widget (yes, widgets and forms can keep track of SEPARATE defaults).
  4. If the form is for an existing record, the value of the record.

My guess is one of 2, 3, or 4 is superseding your widget-level default. Note that 3. supersedes 4. when set default is called after sfFormDoctrine calls updateDefaultsFromObject.

Sign up to request clarification or add additional context in comments.

Comments

2
$this->setDefault("is_tested", false);  // unchecked checkbox

Comments

2

some more examples

$this->widgetSchema['listing_status'] = new sfWidgetFormInputCheckbox(array(),array('value'=>1));
$this->setDefault('listing_status',1);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.