Despite many trials and errors, I cannot get the NumberTextBox widget to work. I keep receiving this error message:
Catchable fatal error: Argument 4 passed to Zend_Dojo_View_Helper_NumberTextBox::numberTextBox() must be an array, null given
The odd thing is: I ev开发者_运维问答ent tried this example straight from the ZF examples page and it failed with the same error
->addElement(
'NumberTextBox',
'numberbox',
array(
'label' => 'NumberTextBox',
'required' => true,
'invalidMessage' => 'Invalid elevation.',
'constraints' => array(
'min' => -20000,
'max' => 20000,
'places' => 0,
)
)
)
So, I'm at a loss now. If someone has the time to look at the code found here, your help would be greatly appreciated. I know it's something that I'm overlooking. It always is.
If you are setting decorators, make sure you change ViewHelper to DijitElement. I ran into this problem and that was the cause.
Shot in the dark: try getting rid of the ',' at the end of 'places' => 0,'
I use a base Form,
BaseForm extends Zend_Dojo_Form{
public $elementDecorators = array(
'DijitElement',
array(
array('data' => 'HtmlTag'),
array('tag' => 'div', 'class' => 'element')
),
array('Label',
array('tag' => 'div', 'class' => 'element-label')
),
array(array('row' => 'HtmlTag'),
array('tag' => 'div', 'class' => 'element-row' )
)
);
... init(){}
.... construct(){}
}
MyForm extends BaseForm{
constructor(){
$this->starts = new Zend_Dojo_Form_Element_DateTextBox( "starts" );
$this->starts->setLabel('Starting from')
->setDecorators($this->elementDecorators);
}
}
I made the source code as simple as possible, to depict the idea of what I mean.
精彩评论