/**
  * Set up form
  */
 public function setup()
 {
     parent::setup();
     $this->setWidget('sf_image_id', new sfWidgetFormInputHidden());
     $this->setWidget('cropped_image', new sfWidgetFormInputFile());
     // Override from the default options
     $options = array('required' => true, 'path' => null);
     $this->setValidator('cropped_image', new sfValidatorImageFile(sfImagePoolUtil::getValidatorOptions($options), sfImagePoolUtil::getValidatorMessages()));
     $this->useFields(array('sf_image_id', 'cropped_image'));
 }
 /**
  * Set up image form
  * 
  * Form options:
  * - use_tags - include tag field (if tagging = true)
  * - embedded - form embedded in object form (to add new images)
  */
 public function setup()
 {
     parent::setup();
     $this->useFields(array('filename', 'credit', 'caption'));
     $this->widgetSchema['caption'] = new sfWidgetFormInputText();
     $this->widgetSchema->setLabel('caption', 'Caption (Alt text)');
     // Override the default options
     $options = array('required' => $this->isNew(), 'path' => $this->getUploadDir());
     $this->setWidget('filename', new sfWidgetFormInputFile());
     $this->setValidator('filename', new sfValidatorImageFile(sfImagePoolUtil::getValidatorOptions($options)), sfImagePoolUtil::getValidatorMessages());
     if ($this->getObject()->option('tagging') && $this->getOption('use_tags', true)) {
         // namespace, key, widget-label
         $this->setTagWidget('Tags');
     }
     // If we're embedding a form then let's reduce it down just to filename
     // for now, and make it non-mandatory
     if ($this->getOption('embedded', false)) {
         $this->useFields(array('filename'));
         $this->getValidator('filename')->setOption('required', false);
     }
 }