i'm using r11367 and running into quite a few problems with the
Zend_Form_Element_File component, e.g. adding two file upload elements to a
form causes a few problems.
The setRequired() element has been given a default
/**
* Set required flag
*
* @param bool $flag Default value is true
* @return Zend_Form_Element
*/
public function setRequired($flag = true)
{
$this->_required = (bool) $flag;
return $this;
}
thomasW wrote:
>
> The setRequired problem has been solved some days ago.
> You have to use r11364 or later where the last change for this component
> has
> been made.
>
> Also I think that setRequired needs a boolean.
>
> Greetings
> Thomas Weidner, I18N Team Leader, Zend Framework
> http://www.thomasweidner.com
>
> ----- Original Message -----
> From: "gerardroche" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Friday, September 12, 2008 4:54 AM
> Subject: Re: [fw-general] Zend_Form_Element_File & MimeType validator
>
>
>>
>> ok, getting some funny goings on.
>>
>> The problem has something to do with setRequired() set to false. Set to
>> true
>> there are no problems.
>>
>> Also, when you add a second File upload element to the form, the second
>> element will recieve the error from the first element?
>>
>> so this is fine:
>>
>> $element = new Zend_Form_Element_File('image');
>> $element->setDecorators($this->_standardElementDecorator)
>> ->setLabel('Upload an image:')
>> ->setRequired()
>> ->addValidator('Count', false, 1)
>> ->addValidator('Size', false, 102400)
>> ->addValidator('Extension', false, 'jpg,png,gif')
>> ->addValidator('MimeType', false, array('image/jpeg',
>> 'image/png', 'image/gif'));
>> $this->addElement($element);
>>
>>
>> remove "setRequired()" and no error
>>
>> $element = new Zend_Form_Element_File('image');
>> $element->setDecorators($this->_standardElementDecorator)
>> ->setLabel('Upload an image:')
>> ->addValidator('Count', false, 1)
>> ->addValidator('Size', false, 102400)
>> ->addValidator('Extension', false, 'jpg,png,gif')
>> ->addValidator('MimeType', false, array('image/jpeg',
>> 'image/png', 'image/gif'));
>> $this->addElement($element);
>>
>> remove "setRequired()" and add extra file upload element and you get one
>> error (the error of the first element on the second element)
>>
>> $element = new Zend_Form_Element_File('image');
>> $element->setDecorators($this->_standardElementDecorator)
>> ->setLabel('Upload an image:')
>> ->addValidator('Count', false, 1)
>> ->addValidator('Size', false, 102400)
>> ->addValidator('Extension', false, 'jpg,png,gif')
>> ->addValidator('MimeType', false, array('image/jpeg',
>> 'image/png', 'image/gif'));
>> $this->addElement($element);
>>
>>
>> $element = new Zend_Form_Element_File('image 2');
>> $element->setDecorators($this->_standardElementDecorator)
>> ->setLabel('Upload an image 2:')
>> ->addValidator('Count', false, 1)
>> ->addValidator('Size', false, 102400)
>> ->addValidator('Extension', false, 'jpg,png,gif')
>> ->addValidator('MimeType', false, array('image/jpeg',
>> 'image/png', 'image/gif'));
>> $this->addElement($element);
>>
>>
>>
>>
>> thomasW wrote:
>>>
>>> I've already added it several days ago.
>>> You can try it out by using the trunk repository or you have to wait
>>> until
>>> the next subrelease comes out.
>>>
>>> Greetings
>>> Thomas Weidner, I18N Team Leader, Zend Framework
>>> http://www.thomasweidner.com
>>>
>>> ----- Original Message -----
>>> From: "gerardroche" <[EMAIL PROTECTED]>
>>> To: <[email protected]>
>>> Sent: Thursday, September 04, 2008 5:45 PM
>>> Subject: [fw-general] Zend_Form_Element_File & MimeType validator
>>>
>>>
>>>>
>>>> Is the MimeType validator available in Zend_Form_Element_File ZF1.6?
>>>>
>>>>
>>>> http://framework.zend.com/manual/en/zend.file.transfer.validators.html
>>>>
>>>>
>>>> $upload = new Zend_File_Transfer();
>>>>
>>>> // Limit the mimetype of all given files to gif images
>>>> $upload->addValidator('MimeType', 'image/gif');
>>>>
>>>> // Limit the mimetype of all given files to gif and jpeg images
>>>> $upload->setValidator('MimeType', array('image/gif', 'image/jpeg');
>>>>
>>>> // Limit the mimetype of all given files to the group images
>>>> $upload->setValidator('MimeType', 'image');
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Zend_Form_Element_File---MimeType-validator-tp19313492p19313492.html
>>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Zend_Form_Element_File---MimeType-validator-tp19313492p19448537.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>
>
--
View this message in context:
http://www.nabble.com/Zend_Form_Element_File---MimeType-validator-tp19313492p19449437.html
Sent from the Zend Framework mailing list archive at Nabble.com.