开发者

About sfWidgetFormInputFileEditable

开发者 https://www.devze.com 2023-03-18 18:16 出处:网络
I\'m tyring to use sfWidgetFormInputFileEditable to upload photos of hotels when I add a new hotel from my backend. This is the description of the w开发者_StackOverflowidget:

I'm tyring to use sfWidgetFormInputFileEditable to upload photos of hotels when I add a new hotel from my backend. This is the description of the w开发者_StackOverflowidget:

The sfWidgetFormInputFileEditable is an input file widget, extending the sfWidgetFormInputFile widget to add the possibility to display or remove a previously uploaded file.

Option      Description
file_src    The current image web source path (required)

As you can see the parameter "file_src" is required, but when I create a new hotel I don't have any "current image web source path" for a new hotel..

What should I do, create a new class based on sfWidgetFormInputFileEditable whose option "file_src" is not required? What do you think is smart solution?

sf 1.4

Javi


This parameter is used only in edit mode... so, you can fill it with the path of the future image, like this:

$this->widgetSchema['cover'] = new sfWidgetFormInputFileEditable(array(
  'label'     => 'Company logo',
  'file_src'  => '/uploads/covers/'.$this->getObject()->getCover(),
  'is_image'  => true,
  'edit_mode' => !$this->isNew(),
  'template'  => '<div>%file%<br />%input%<br />%delete% %delete_label%</div>',
));

look at the edit_mode parameter based on the isNew form's attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号