I have this form class:
class NewsItemForm extends BaseNewsItemForm
{
public function configure()
{
$this->useFields(array('title', 'picture', 'text'));
$this->widgetSchema['picture'] = new
sfWidgetFormInputFileEditable(array(
'file_src' => '/uploads/'.$this->getObject()->getPicture(),
'is_image' => true,
'edit_mode' => !$this->isNew(),
'template' => '<div>%file%<br />%input%<br />%delete%
%delete_label%</div>',
));
$this->validatorSchema['picture'] = new sfValidatorFile(array(
'mime_types' => 'web_images',
'path' => sfConfig::get('sf_upload_dir'),
'required' => true,
'validated_file_class' =>
'myValidatedResizedFile'));
}
}
I submit the form correctly, after that, the same form is showed this
time to update the data submited, but the problem is it’s not
retrieving the info about the picture, I mean, the picture is showed
but next to the “Browse..” button there is written “No file chosen”,
in fact, if I try to submit the form I get the error message
“Required” for the picture field.
Any idea?
sf 1.4.
Regards
Javi
Just add ‘required’ => $this->isNew():