Mam problem z osadzonym formularzem, oto klasa formularza:
class BackendEmbedImageForm extends ImageForm
{
public function configure()
{
unset($this['product_id'], $this['ord'], $this['name']);
$this->widgetSchema['image'] = new sfWidgetFormInputFileEditable
(array( '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:'
));
$this->validatorSchema['image'] = new sfValidatorFile
(array( '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:
public function bind
(array $taintedValues = null, array $taintedFiles = null) {
if (WARUNEK)
{
$this->embeddedForms['image1']->getObject()->setProduct($this->getObject());
} else {
unset($this->embeddedForms['image1'], $taintedValues['image1']); $this->validatorSchema['image1'] = new sfValidatorPass();
}
...
probowalem sprawdzac w nastpeujacy sposob $taintedFiles[image1][image] i czy ta zmienna jest pusta, ale nie dziala, jakis pomysl?