![]() |
|
Code snippets for symfony 1.x |
|
Common Probem.
You have a large and small form. For example a contact form.
Form orginal includes 50 fields and your small form is extend form the orginal form and includes 15 fields. normaly you have to unset very 35 field in the small one.
But you could also write this lines:
class ContactSimpleForm extends ContactForm { public function configure() { parent::configure(); $this->wantedFields = array( 'firstname', 'lastname', ); foreach ($this as $fieldName => $widget){ if (!in_array($fieldName, $this->wantedFields)){ unset($this->widgetSchema[$fieldName]); unset($this->validatorSchema[$fieldName]); } } }