Hi !
I have a problem with a BackendForm where I use a
sfWidgetFormInputFileEditable on a parameter called "image". This
image has to be put in a folder that depends on another parameter of
the "Horse" which is a slugified version of its "name". Now below you
have my code for the BackendKdHorseForm class. This code works just
fine with already existing Horse, because $this->getObject()-
>getNameSlug() returns the right value, but when I try to create a new
Horse, the picture always ends up in :
uploads/images/pferde/
instead of :
uploads/images/pferde/%the_corresponding_slug%
Now I did try to use a slugified version of $this->getValue('name')
but didn't work any better...
Any suggestions ?
class BackendKdHorseForm extends KdHorseForm
{
public function configure()
{
parent::configure();
$this->widgetSchema['image'] = new sfWidgetFormInputFileEditable
(array(
'label' => 'Bild',
'file_src' => '/uploads/images/pferde/'.$this->getObject()-
>getNameSlug().'/'.$this->getObject()->getImage(),
'is_image' => true,
'edit_mode' => !$this->isNew(),
'template' => '<table class="null"><tr><td colspan="2">%file%</
td></tr><tr><td colspan="2">%input%</td></tr><tr><td>%delete%</td><td>
%delete_label%</td></tr></table>',
));
$this->validatorSchema['image'] = new sfValidatorFile(array(
'required' => false,
'path' => sfConfig::get('sf_upload_dir').'/images/pferde/'.
$this->getObject()->getNameSlug(),
'mime_types' => 'web_images',
'validated_file_class' => 'sfValidatedFileOriginalName'
));
$this->validatorSchema['image_delete'] = new sfValidatorPass();
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---