I got and Zend Form which does this:
class Products_AddForm extends Zend_Form {
public function init() {
$ProductImage1 = $mainform->addElement('file', 'Productimage1', array(
'validators' => array(
array('Count', false, '1' ),
array('Size', false, '10MB'),
array('Extension', false, 'jpg,jpeg,tif,eps'),
),
'required' => false,
'label' => 'Product Image1 (jpg/tif/eps)'
));
Then an Controller which checks the post data:
public function addAction()
{
$form = $this->getAddForm();
if($this->getRequest()->isPost()){
$post = $this->getRequest()->getPost();
// check post data
if($form->isValid($post) )
{
}
else {
print_r($form->getErrors());
print_r($form->getErrorMessages());
print_r($form->getMessages());
}
And a custom view controller something like this:
echo '<form method="post" action="'.$this->baseUrl('products/add').'" enctype="multipart/form-data">';
$image1 = $form->getElement('Productimage1');
$helper1 = $image1->helper;
echo '<br/>'.$this->translate('Productimage').' (jpg/tif):<br/>'.$bild1->getView()->$helper1(
$image1->getName(),
$image1->getValue(),
$image1->getAttribs(),
$image1->options
);
When I just type some information in textfields and post it, $form->isValid() goes false. When I delete the file parts from the form and the custom view, it works perfectly.
Formelement is on 'required' false. In addition the false part of the controller -> getErrors(), getMessages() and getErrorMessages() returns no errors?!
Does anybody knows whats going on here?