Re: [fw-general] Zend_Form and File upload
I don't know if anything else helped you, but this error happens when the multipart encoding is not present. Set the encoding in the form tag and it should solve your problem. I don't think decorators matter but I may be wrong :P It did not matter for the code I was looking at Regards, A -- View this message in context: http://www.nabble.com/Zend_Form-and-File-upload-tp21548629p23686238.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Form and File upload
Michel, I think you misunderstood me... You erased the file decorator. Without the file decorator the file element will not be rendered correct. See the link I sent you in my previous mail. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Michel Morelli mic...@ziobuddalabs.it To: Thomas Weidner thomas.weid...@gmx.at Sent: Tuesday, January 20, 2009 10:28 AM Subject: Re: [fw-general] Zend_Form and File upload Thomas Weidner ha scritto: Btw: What is $decorators ? Why are you erasing the file decorator ? Is there any reason for this ? Simple: I want every form element enclosed into a div element. And in this way it works. I don't think that my decorators are linked with element error. M. -- Michel 'ZioBudda' Morelli mic...@ziobuddalabs.it Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.itMSN: mic...@ziobuddalabs.it JABBER: mic...@gmail.com
Re: [fw-general] Zend_Form and File upload
Michel, this discussion is useless... Please read the link I provided in a previous mail. The FAQ answers all your questions. You even find an example there. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Michel Morelli mic...@ziobuddalabs.it To: Thomas Weidner thomas.weid...@gmx.at Sent: Tuesday, January 20, 2009 12:15 PM Subject: Re: [fw-general] Zend_Form and File upload Thomas Weidner ha scritto: Michel, I think you misunderstood me... You erased the file decorator. Without the file decorator the file element will not be rendered correct. My element file is rendered correct. I see it in the html form. I use ViewScript, too. M. -- Michel 'ZioBudda' Morelli mic...@ziobuddalabs.it Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.itMSN: mic...@ziobuddalabs.it JABBER: mic...@gmail.com
[fw-general] Zend_Form and File upload
Hi all. I have this file upload element and it is a NOT required element (setRequired(false)): $mainpic = $this-createElement('file','mainpic'); $mainpic-setLabel('Immagine di riferimento:') -setDestination('/tmp'); // ensure only 1 file //$mainpic-addValidator('Count', false, 1); // limit to 100K $mainpic-addValidator('Size', false, 102400); // only JPEG, PNG, and GIFs $mainpic-addValidator('Extension', false, 'jpg,png,gif'); $mainpic-setDecorators($decorators) -addDecorator('HtmlTag',array('tag' = 'div', 'class' = 'field_mainpic')) -addDecorator('Description', array('escape' = false, 'tag' = 'span', 'class' = 'description')); My problem is that when I click the submit button my form is not valid and the error is in the file element, and these are the error messages : * The file '' could not be found * The file '' was not found Where is my error ? The problem are the 'Count' and 'Extension' validator, but why they run if the file is not required ? M. -- Michel 'ZioBudda' Morelli mic...@ziobuddalabs.it Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.it MSN: mic...@ziobuddalabs.it JABBER: mic...@gmail.com
Re: [fw-general] Zend_Form and File upload
You must have deleted one line because you did not set setRequired(false) in your code. This means that the file element must be given as it's required. And this means that the file will ALWAYS be validated and returns a failure message when no file is given. Add setRequired(false) to your code to set the file element to be optional. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Michel Morelli mic...@ziobuddalabs.it To: fw-general@lists.zend.com Sent: Monday, January 19, 2009 7:16 PM Subject: [fw-general] Zend_Form and File upload Hi all. I have this file upload element and it is a NOT required element (setRequired(false)): $mainpic = $this-createElement('file','mainpic'); $mainpic-setLabel('Immagine di riferimento:') -setDestination('/tmp'); // ensure only 1 file //$mainpic-addValidator('Count', false, 1); // limit to 100K $mainpic-addValidator('Size', false, 102400); // only JPEG, PNG, and GIFs $mainpic-addValidator('Extension', false, 'jpg,png,gif'); $mainpic-setDecorators($decorators) -addDecorator('HtmlTag',array('tag' = 'div', 'class' = 'field_mainpic')) -addDecorator('Description', array('escape' = false, 'tag' = 'span', 'class' = 'description')); My problem is that when I click the submit button my form is not valid and the error is in the file element, and these are the error messages : * The file '' could not be found * The file '' was not found Where is my error ? The problem are the 'Count' and 'Extension' validator, but why they run if the file is not required ? M. -- Michel 'ZioBudda' Morelli mic...@ziobuddalabs.it Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.itMSN: mic...@ziobuddalabs.it JABBER: mic...@gmail.com
Re: [fw-general] Zend_Form and File upload
Btw: What is $decorators ? Why are you erasing the file decorator ? Is there any reason for this ? See the FAQ for details: Point 3 http://framework.zend.com/wiki/display/ZFFAQ/Forms Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Michel Morelli mic...@ziobuddalabs.it To: fw-general@lists.zend.com Sent: Monday, January 19, 2009 7:16 PM Subject: [fw-general] Zend_Form and File upload Hi all. I have this file upload element and it is a NOT required element (setRequired(false)): $mainpic = $this-createElement('file','mainpic'); $mainpic-setLabel('Immagine di riferimento:') -setDestination('/tmp'); // ensure only 1 file //$mainpic-addValidator('Count', false, 1); // limit to 100K $mainpic-addValidator('Size', false, 102400); // only JPEG, PNG, and GIFs $mainpic-addValidator('Extension', false, 'jpg,png,gif'); $mainpic-setDecorators($decorators) -addDecorator('HtmlTag',array('tag' = 'div', 'class' = 'field_mainpic')) -addDecorator('Description', array('escape' = false, 'tag' = 'span', 'class' = 'description')); My problem is that when I click the submit button my form is not valid and the error is in the file element, and these are the error messages : * The file '' could not be found * The file '' was not found Where is my error ? The problem are the 'Count' and 'Extension' validator, but why they run if the file is not required ? M. -- Michel 'ZioBudda' Morelli mic...@ziobuddalabs.it Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.itMSN: mic...@ziobuddalabs.it JABBER: mic...@gmail.com
Re: [fw-general] Zend_Form and File upload
To correct myself... Elements are not required per default. I was just irritated that you noted that you've called setRequired(false) but did not find this in your example code. But deleting the default decorator without adding a own file decorator means that the file element is not rendered correct. Therefor the failure you got. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Thomas Weidner thomas.weid...@gmx.at To: fw-general@lists.zend.com Sent: Monday, January 19, 2009 7:49 PM Subject: Re: [fw-general] Zend_Form and File upload You must have deleted one line because you did not set setRequired(false) in your code. This means that the file element must be given as it's required. And this means that the file will ALWAYS be validated and returns a failure message when no file is given. Add setRequired(false) to your code to set the file element to be optional. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Michel Morelli mic...@ziobuddalabs.it To: fw-general@lists.zend.com Sent: Monday, January 19, 2009 7:16 PM Subject: [fw-general] Zend_Form and File upload Hi all. I have this file upload element and it is a NOT required element (setRequired(false)): $mainpic = $this-createElement('file','mainpic'); $mainpic-setLabel('Immagine di riferimento:') -setDestination('/tmp'); // ensure only 1 file //$mainpic-addValidator('Count', false, 1); // limit to 100K $mainpic-addValidator('Size', false, 102400); // only JPEG, PNG, and GIFs $mainpic-addValidator('Extension', false, 'jpg,png,gif'); $mainpic-setDecorators($decorators) -addDecorator('HtmlTag',array('tag' = 'div', 'class' = 'field_mainpic')) -addDecorator('Description', array('escape' = false, 'tag' = 'span', 'class' = 'description')); My problem is that when I click the submit button my form is not valid and the error is in the file element, and these are the error messages : * The file '' could not be found * The file '' was not found Where is my error ? The problem are the 'Count' and 'Extension' validator, but why they run if the file is not required ? M. -- Michel 'ZioBudda' Morelli mic...@ziobuddalabs.it Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.itMSN: mic...@ziobuddalabs.it JABBER: mic...@gmail.com
Re: [fw-general] Zend_Form with file upload field
Or you could also create a new element type 'File'. require_once 'Zend/Form/Element/Xhtml.php'; class My_Form_Element_File extends Zend_Form_Element_Xhtml { protected $_defaultHelper = 'formFile'; } On Feb 7, 2008 4:27 PM, drews [EMAIL PROTECTED] wrote: Hi Laurent, laurent5la wrote: I was wondering if someone used Zend_Form_Element_File. I need to create a form with a File upload button. input name=uploadFile1 type=file id=uploadFile1 as the file-element isn't implemented yet in the Zend_Form component, you could fake it yourself by doing a quick and dirty hack right into the Zend/Form/Decorator. Create a new Decorator and call it i.e. UploadWrapper: class Zend_Form_Decorator_UploadWrapper extends Zend_Form_Decorator_Abstract { public function render($content) { return input type=file name=FileUpl id=FileUpl/ .; } } notice, in this case you simply ignore $content, which would be the rendered stuff that comes from the ZF itself. then you can simply write sth. like this in your controller (or as in this case, in your form-class, that extends Zend_Form): $Upl = new Zend_Form_Element_Text('FileUpl'); $Upl-setLabel('Upload:') -setDecorators( array( array('ViewHelper', array('helper' = 'formFile')), array('Label', array('style' = 'display:block;')), array('UploadWrapper') ) ); and add the element to the form via $this-addElement(array($FileUpl)); Not a good solution, but it works (at least in over here and at the moment of writing this ;)) best -Wolfgang -- German Servicepoint for PHP since 1999: Dynamic Web Pages: http://www.dynamic-webpages.de/ PHP-Training Certification http://www.phpzertifizierung.eu/ -- View this message in context: http://www.nabble.com/Zend_Form-with-file-upload-field-tp15326842s16154p15334963.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Form with file upload field
Hi Laurent, laurent5la wrote: I was wondering if someone used Zend_Form_Element_File. I need to create a form with a File upload button. input name=uploadFile1 type=file id=uploadFile1 as the file-element isn't implemented yet in the Zend_Form component, you could fake it yourself by doing a quick and dirty hack right into the Zend/Form/Decorator. Create a new Decorator and call it i.e. UploadWrapper: class Zend_Form_Decorator_UploadWrapper extends Zend_Form_Decorator_Abstract { public function render($content) { return input type=file name=FileUpl id=FileUpl/ .; } } notice, in this case you simply ignore $content, which would be the rendered stuff that comes from the ZF itself. then you can simply write sth. like this in your controller (or as in this case, in your form-class, that extends Zend_Form): $Upl = new Zend_Form_Element_Text('FileUpl'); $Upl-setLabel('Upload:') -setDecorators( array( array('ViewHelper', array('helper' = 'formFile')), array('Label', array('style' = 'display:block;')), array('UploadWrapper') ) ); and add the element to the form via $this-addElement(array($FileUpl)); Not a good solution, but it works (at least in over here and at the moment of writing this ;)) best -Wolfgang -- German Servicepoint for PHP since 1999: Dynamic Web Pages: http://www.dynamic-webpages.de/ PHP-Training Certification http://www.phpzertifizierung.eu/ -- View this message in context: http://www.nabble.com/Zend_Form-with-file-upload-field-tp15326842s16154p15334963.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Form with file upload field
-- laurent5la [EMAIL PROTECTED] wrote (on Wednesday, 06 February 2008, 07:43 PM -0800): I was wondering if someone used Zend_Form_Element_File. I need to create a form with a File upload button. input name=uploadFile1 type=file id=uploadFile1 Once Zend_(File_?)Upload is ready, we'll create a form element for this. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Zend_Form with file upload field
Thanks Wolfgang and Amr for your much appreciated help. I ended up implementing the later one which is creating a new element and it works fine. FYI I'm working on a tool to upload and resize images using Zend_Form. and Matthew thks for the update and this very useful component.=) Laurent Matthew Weier O'Phinney-3 wrote: -- laurent5la [EMAIL PROTECTED] wrote (on Wednesday, 06 February 2008, 07:43 PM -0800): I was wondering if someone used Zend_Form_Element_File. I need to create a form with a File upload button. input name=uploadFile1 type=file id=uploadFile1 Once Zend_(File_?)Upload is ready, we'll create a form element for this. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/ -- View this message in context: http://www.nabble.com/Zend_Form-with-file-upload-field-tp15326842s16154p15342687.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Zend_Form with file upload field
Hi , I was wondering if someone used Zend_Form_Element_File. I need to create a form with a File upload button. input name=uploadFile1 type=file id=uploadFile1 Thanks Laurent -- View this message in context: http://www.nabble.com/Zend_Form-with-file-upload-field-tp15326842s16154p15326842.html Sent from the Zend Framework mailing list archive at Nabble.com.