2008年8月28日星期四

Re: [fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

Tobias Gies wrote:
>
> Hi Václav,
>
> as an educated guess, I'd say you did not tell Zend_Form to use the view
> you
> added your custom helpers to. Search Zend_Form::setView() in the docs :-).
>
> Best regards
> Tobias
>
> 2008/8/27 Václav Vaník <vanik@walk.cz>
>
>>
>> OK, I create my own:
>>
>> Walk_View_Helper_FormMultiCheckboxFilter extends
>> Zend_View_Helper_FormMultiCheckbox
>>
>> I added path to helper in bootstrap:
>>
>> $view->addHelperPath(ROOT_DIR . '/app/valhalla/helpers',
>> 'Walk_View_Helper');
>>
>> Then I set decorator to multicheckbox element:
>>
>> $checkbox->setDecorators(array('ViewHelper', array('helper' =>
>> 'formMultiCheckboxFilter')));
>>
>> but when I render form I get error:
>>
>> Warning: Plugin by name FormMultiCheckboxFilter was not found in the
>> registry. in /path/library/Zend/Form/Element.php on line 1892
>>
>> How could I fix it?
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19183452.html
>> Sent from the Zend MVC mailing list archive at Nabble.com.
>>
>>
>
>

Damn, you're right :)

I set to form the view, which i defined in bootstrap, but it still doesnt
work, it throws same warning.

My form is defined:

$form = new Zend_Form();
$form->setAction($this->view->url(array('controller' => 'user'),
null, true))
->setMethod(Zend_Form::METHOD_GET)
->setAttrib('id', 'indexUser')
->setElementFilters(array('StringTrim'))
->setView($this->_helper->viewRenderer->view)
->setDecorators(array(array('viewScript', array('viewScript' =>
'user/index-form.phtml'))));

$id = $form->createElement('text', 'fId', array('size' =>
1));

$firstname = $form->createElement('text', 'fFirstname',
array('size' => 12));
$lastname = $form->createElement('text', 'fLastname', array('size'
=> 12));

$checkAll = $form->createElement('checkbox', 'checkAll');
$checkbox = $form->createElement('multiCheckbox', 'checkboxIds')
->setDecorators(array('ViewHelper',
array('helper' => 'formMultiCheckboxFilter')));

$submit = $form->createElement('submit',
'sent')->setLabel('filtrovat');
$command = $form->createElement('submit',
'command')->setLabel('provést');

$form->addElement($id)
->addElement($firstname)
->addElement($lastname)
->addElement($checkAll)
->addElement($submit)
->addElement($command)
->setElementDecorators(array('ViewHelper'))
->addElement($checkbox);
--
View this message in context: http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19196844.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: