/** * Overridden to allow the app to add to the form and then to process * those additions and turn them into one giant, embedded form */ public function setup() { // allow the application to add fields to the form self::$dispatcher->notify(new sfEvent($this, 'sympal.load_config_form')); $otherSettings = array(); foreach ($this->_settings as $group => $settings) { if (!is_numeric($group)) { $form = new BaseForm(); foreach ($settings as $setting) { $form->setWidget($setting['name'], $setting['widget']); $form->getWidgetSchema()->setLabel($setting['name'], $setting['label']); $form->setValidator($setting['name'], $setting['validator']); } $this->embedForm($group, $form); } else { $otherSettings[] = $settings; } } foreach ($otherSettings as $setting) { $this->setWidget($setting['name'], $setting['widget']); $this->getWidgetSchema()->setLabel($setting['name'], $setting['label']); $this->setValidator($setting['name'], $setting['validator']); } $defaults = $this->getDefaults(); foreach ($this as $key => $value) { if ($value instanceof sfFormFieldSchema) { foreach ($value as $k => $v) { $defaults[$key][$k] = sfSympalConfig::get($key, $k); } } else { $defaults[$key] = sfSympalConfig::get($key); } } $this->setDefaults($defaults); $this->widgetSchema->setNameFormat('settings[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); parent::setup(); }