I have in Symfony 1.4 form:
$this->setWidget('title', new sfWidgetFormInputText());
$this->setWidget('photo', new sfWidgetFormInputFile());
if i send this form, and he is valid then show me page with error. In input TITLE is previous text, which i entered, but no link to attach files. I must again search this file and select. How can i fix it?
In short, you can’t. This is a symptom of HTML file inputs.
A file input takes a the local path of the file on the client’s machine (not the server), so consider this (hypothetical) scenario:
It would be a major security risk also. Let’s say you write a malicious script which contains a form and file input. If you knew the path to a file on the client’s machine then you could pre-populate the file input and then submit the form with JavaScript to force the user to upload the file.
This is why you can’t pre-populate a file input in HTML.
As an alternative you should use
sfWidgetFormInputFileEditablewhich will display the previously uploaded image alongside the file input. However, this will only display once the form has submitted and saved successfully.