views:

20

answers:

1

Hi,

I have a Zend form like this:

     $this->setName('Add Job');
  $id = new Zend_Form_Element_Hidden('id');
  $id->addFilter('Int');

  $name = new Zend_Form_Element_Text('name');
  $name->setLabel('Name')
  ->setRequired(true)
  ->addFilter('StripTags')
  ->addFilter('StringTrim')
  ->addValidator('NotEmpty'); 

  $file = new Zend_Form_Element_File('file');
  $file->setLabel('File')
  ->setRequired(true);

  $category = new Zend_Form_Element_Checkbox('category');
  $category->setLabel('Express?')
  ->setRequired(true)
  ->setCheckedValue('2')
  ->setUncheckedValue('1');   

  $submit = new Zend_Form_Element_Submit('submit');
  $submit->setAttrib('id', 'submitbutton');

The "add" action is working fine but I'm not working on the "edit" action using this in my controller:

 $id = $this->_getParam('id', 0);    
 if ($id > 0) {
      $jobs = new Application_Model_DbTable_Jobs();
      $form->populate($jobs->getJob($id));
 }

and the form prepopulates just fine except for the file element. In the DB, I've got the filename saved and I'd like to display it in the edit form somehow - is there a standard way of handling this in Zend?

Thanks,

Phil

+1  A: 

You cannot prepopulate a file-input-element.
That is not a restriction by Zend_Form. The html input-file-element has no "value" attribute.

Benjamin Cremer
yes, quite right. thanks!
phil
@phill consider to accept my answer. just for the completeness ;)
Benjamin Cremer