class BackendEmbedImageForm extends ImageForm { public function configure() { 'file_src' => sfConfig::get('sf_upload_dir') . '/foto/m' . $this->getObject()->getImage(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '%file% %input%', 'label' => 'Zdjęcie:' )); 'path' => sfConfig::get('sf_upload_dir') . '/foto/', 'required' => false, 'mime_types' => 'web_images' )); } }
W klasie formualrza modelu, konfiguracja formualrza:
$imageForm = new BackendEmbedImageForm(); $this->embedForm('image1', $imageForm); $this->widgetSchema['image1']->setLabel('Dodaj zdjęcie #1');
teraz w funkcji bind chce sprawdzic czy plik zostal wybrany:
{ if (WARUNEK) { $this->embeddedForms['image1']->getObject()->setProduct($this->getObject()); } else { $this->validatorSchema['image1'] = new sfValidatorPass(); } ...
probowalem sprawdzac w nastpeujacy sposob $taintedFiles[image1][image] i czy ta zmienna jest pusta, ale nie dziala, jakis pomysl?