/** * DOCUMENT ME */ public function setup() { parent::setup(); unset($this['created_at']); unset($this['updated_at']); unset($this['owner_id']); unset($this['lucene_dirty']); $this->setWidget('tags', new sfWidgetFormInput(array("default" => implode(", ", $this->getObject()->getTags())), array("class" => "tag-input", "autocomplete" => "off"))); $this->setValidator('tags', new sfValidatorPass()); $this->setWidget('view_is_secure', new sfWidgetFormSelect(array('choices' => array('1' => 'Hidden', '' => 'Public')))); $this->setWidget('description', new aWidgetFormRichTextarea(array('tool' => 'Media', 'height' => 182))); // FCK doesn't like to be smaller than 182px in Chrome $this->setValidator('view_is_secure', new sfValidatorChoice(array('required' => false, 'choices' => array('1', '')))); $q = $this->getCategoriesQuery(); $this->setWidget('categories_list', new sfWidgetFormDoctrineChoice(array('query' => $q, 'model' => 'aCategory', 'multiple' => true))); $this->setValidator('categories_list', new sfValidatorDoctrineChoice(array('query' => $q, 'model' => 'aCategory', 'multiple' => true, 'required' => false))); $categories = $q->execute(); $this->widgetSchema->setLabel('categories_list', 'Categories'); $this->setValidator('title', new sfValidatorString(array('min_length' => 3, 'max_length' => 200, 'required' => true), array('min_length' => 'Title must be at least 3 characters.', 'max_length' => 'Title must be <200 characters.', 'required' => 'You must provide a title.'))); $this->setWidget('view_is_secure', new sfWidgetFormSelectRadio(array('choices' => array(0 => 'Public', 1 => 'Hidden'), 'default' => 0))); $this->setValidator('view_is_secure', new sfValidatorBoolean()); $this->widgetSchema->setLabel('view_is_secure', 'Permissions'); $this->widgetSchema->setLabel('categories_list', 'Categories'); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); if ($this->isAdmin()) { // Only admins can add more categories $this->setWidget('categories_list_add', new sfWidgetFormInput()); $this->setValidator('categories_list_add', new sfValidatorPass()); } // If I don't unset this saving the form will purge existing relationships to slots unset($this['slots_list']); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'postValidator')))); }
public function setup() { parent::setup(); unset($this['created_at']); unset($this['updated_at']); unset($this['owner_id']); $this->setWidget('tags', new sfWidgetFormInput(array("default" => implode(", ", $this->getObject()->getTags())), array("class" => "tag-input", "autocomplete" => "off"))); $this->setValidator('tags', new sfValidatorPass()); $this->setWidget('view_is_secure', new sfWidgetFormSelect(array('choices' => array('1' => 'Hidden', '' => 'Public')))); $this->setWidget('description', new sfWidgetFormRichTextarea(array('editor' => 'fck', 'tool' => 'Media'))); $this->setValidator('view_is_secure', new sfValidatorChoice(array('required' => false, 'choices' => array('1', '')))); $this->widgetSchema->setLabel('media_categories_list', 'Categories'); // If I don't unset this saving the form will purge existing relationships to slots unset($this['slots_list']); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); }