Hi, I've created a simple upload-form and got a little problem when submitting the data.
The file is uploaded correctly, but my little description field stays null.
Here's my form:
class Upload_Form_Uploadvideo extends Zend_Form{
public function init()
{
$this->setName('video')
->setAction('interface/videoupload')
->setMethod('post');
#id
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
#Textfield "Videofile"
$video = new Zend_Form_Element_File('videofile', array(
'label' => 'Videofile')
);
$video->setDestination(APPLICATION_PATH.'/upload/video/toConvert/');
#Textfield "Videofile"
$desc = new Zend_Form_Element_Text('videodescription', array(
'label' => 'Description')
);
$desc->setAttrib('value','The description is not optional!');
$desc->setAttrib('size','25');
#Submit
$submit = new Zend_Form_Element_Submit('submit', array('label' => 'Upload Video'));
$submit->setAttrib('id', 'submitbutton');
#bringing everything together
$this->addElements(array($id,$video,$desc,$submit));
}
}
the controller, giving it to the view:
public function videouploadAction()
{
#in production this code goes to the index()
if(!$this->getRequest()->isPost()){
return $this->_forward('index');
}
$form = $this->getForm();
$this->view->via_getpost = var_dump($this->_request->getPost());
$this->view->via_getvalues= var_dump($form->getValues());
}
Now, I var_dump $this->_request->getPost() and $form->getValues().
The output is the following:
array[$this->_request->getPost()]
'id' => string '0' (length=1)
'MAX_FILE_SIZE' => string '134217728' (length=9)
'videodescription' => string 'This is a test-video' (length=20)
'submit' => string 'Upload Video' (length=12)
array [$form->getValues()]
'id' => int 0
'videofile' => string 'swipeall.avi' (length=12)
'videodescription' => null
In addition, I set the "value"-attrib, without any effect. I intended to write something in the box, when the user loads the site.
I'm new to Zend, so I guess I'm just overseeing something stupid, though I can't find it.
Thx for your help