Ejemplo n.º 1
0
 public function configure()
 {
     // remove undesired fields
     unset($this["created_at"], $this["updated_at"], $this["is_default"]);
     // customize is active
     $this->widgetSchema["is_active"] = new sfWidgetFormSelect(array('choices' => array('0' => 'Disabled', '1' => 'Enabled')));
     if ($this->getObject()->getIsDefault()) {
         $this->widgetSchema["is_active"]->setAttribute("disabled", true);
     }
     $this->validatorSchema["is_active"] = new sfValidatorChoice(array('choices' => array('1', '0'), 'required' => true));
     // customize template
     $this->widgetSchema["template"] = new sfWidgetFormSelect(array('choices' => BadgePeer::retrieveTemplates()));
     $this->validatorSchema["template"] = new sfValidatorChoice(array('choices' => array_keys(BadgePeer::retrieveTemplates())));
     // customize name
     $this->validatorSchema["name"]->setOption("trim", true);
     $this->validatorSchema["name"]->setMessage("required", "Please enter the badge name");
     // customize thumbnail
     $this->widgetSchema["thumbnail"] = new sfWidgetFormInputFile();
     $this->validatorSchema["thumbnail"] = new sfValidatorFile(array('required' => false, 'max_size' => 1024 * 1024, 'mime_types' => array('image/jpeg', 'image/pjpeg')), array('required' => 'Please upload a file', 'invalid' => 'Only JPEG images are allowed'));
     $this->widgetSchema->setLabel('thumbnail', 'Upload thumbnail (JPEG max 1M)');
     // remove thumbnail
     $this->widgetSchema["remove_thumbnail"] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema["remove_thumbnail"] = new sfValidatorBoolean();
 }