public function setup()
 {
     parent::setup();
     $this->validatorSchema->setOption('allow_extra_fields', true);
     unset($this['site_id'], $this['created_at'], $this['updated_at'], $this['last_updated_by_id'], $this['slots_list'], $this['links_list'], $this['assets_list'], $this['comments_list']);
     $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator();
     $this->widgetSchema['theme'] = $field['widget'];
     $this->validatorSchema['theme'] = $field['validator'];
     // Sets up the template widget
     sfSympalFormToolkit::changeTemplateWidget($this);
     // Sets up the module widget
     sfSympalFormToolkit::changeModuleWidget($this);
     if (!$this->object->content_type_id) {
         $this->object->Type = Doctrine_Core::getTable('sfSympalContentType')->findOneBySlug('page');
     } else {
         $this->object->Type;
     }
     $this->configureMenuSection();
     $this->_embedTypeForm();
 }
 public function setup()
 {
     parent::setup();
     $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator();
     $this->widgetSchema['theme'] = $field['widget'];
     $this->validatorSchema['theme'] = $field['validator'];
     $this->widgetSchema['name']->setLabel('Model name');
     $models = Doctrine_Core::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine');
     // Sets up the template widget
     sfSympalFormToolkit::changeTemplateWidget($this);
     // Sets up the module widget
     sfSympalFormToolkit::changeModuleWidget($this);
     foreach ($models as $model) {
         $table = Doctrine_Core::getTable($model);
         if (!$table->hasTemplate('sfSympalContentTypeTemplate')) {
             unset($models[$model]);
         }
     }
     $models = array_merge(array('' => ''), $models);
     $this->widgetSchema['name'] = new sfWidgetFormChoice(array('choices' => $models));
 }
 public function run(sfEvent $event)
 {
     $form = $event->getSubject();
     if ($form instanceof sfFormDoctrine) {
         sfSympalFormToolkit::embedI18n($form->getObject(), $form);
         if (sfSympalConfig::get('remove_timestampable_from_forms', null, true)) {
             unset($form['created_at'], $form['updated_at']);
         }
     }
     $widgetSchema = $form->getWidgetSchema();
     $requiredFields = $form->getRequiredFields();
     $widgetSchema->addOption('required_fields', $requiredFields);
     $widgetSchema->addFormFormatter('table', new sfSympalWidgetFormSchemaFormatterTable($widgetSchema));
     if ($form->hasRecaptcha()) {
         sfSympalFormToolkit::embedRecaptcha($form);
     }
     if (isset($form['template'])) {
         sfSympalFormToolkit::changeTemplateWidget($form);
     }
     if (isset($form['theme'])) {
         sfSympalFormToolkit::changeThemeWidget($form);
     }
     if (isset($form['module'])) {
         sfSympalFormToolkit::changeModuleWidget($form);
     }
     if (isset($form['content_id']) || isset($form['content_list'])) {
         sfSympalFormToolkit::changeContentWidget($form);
     }
     $richDateForms = sfSympalConfig::get('rich_date_forms');
     $formClass = get_class($form);
     if (isset($richDateForms[$formClass])) {
         foreach ($form as $name => $field) {
             $widget = $field->getWidget();
             if (in_array($name, $richDateForms[$formClass]) && ($widget instanceof sfWidgetFormDateTime || $widget instanceof sfWidgetFormDate)) {
                 sfSympalFormToolkit::changeDateWidget($name, $form);
             }
         }
     }
 }