2008年9月23日星期二

[fw-mvc] Zend_Form_Decorator_ViewScript

Hello everyone,

I am using Zend_Form to create an upload form, my form works fine without
using the ViewScript Decorator, but I want to give the ViewScript decorator
a try since it provides a control over the elements, but I got this error
(Warning: No view script registered with ViewScript decorator) and I am not
able to figure out the solution. here is my code:

private function createForm() {
//Create an Instance of the Zend Form Class
$form = new Zend_Form ( );
//set the view of the form
$view = new Zend_View();
$view->setScriptPath('../Views/templates/');
$form->setView ( $view ); //create the form
$form->setAction (
'http://flv.m3com.com.sa/uploadTravel.php?cat=kids' )
->setMethod ( 'post' )
->setEnctype ( Zend_Form::ENCTYPE_MULTIPART )
->setName('picture');

//Create the elements of the form //Create and
configure childname element:
$childName = $form->createElement ( 'text', 'childName' );
$childName->setRequired ( true )
->setAttrib ( 'class', 'text' )
->setLabel ( name )
->addValidator ( 'StringLength', false, array (1, 40 ) )
->addErrorMessage ( 'tooLongName' ); .
.
.
. Other Form Elements
.
.
.
$childSubmit = $form->createElement ( 'image', 'submit' );
$childSubmit->setImage(IMAGE_PATH . 'upload-btn.gif')
->setImageValue('upload')
->setAttribs ( array ( 'alt' => 'upload', 'onClick' =>
'return checkData();' ) )->setRequired ( false )->setIgnore ( true );
//add the created elements to the form object
$form->addElements ( array ($childName, $hiddenImage, $childCounties,
$childCities, $childImage, $childBirthday, $childHobbie, $childSubmit
) );
$form->setDecorators( array( array('ViewScript',
array('ViewScript' => 'uploadForm.phtml'))));
return $form;
}

PS: I am using the Zend_Form as a component and I am not using the
Zend_Controller component. could anyone help me please.

Thanks in advance.

Nayef Abu Ebaid

--
View this message in context: http://www.nabble.com/Zend_Form_Decorator_ViewScript-tp19638477p19638477.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: