开发者

About sfWidgetFormInputFileEditable

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜