我正在使用ZendX_JQuery dialogContainer视图助手,为了产生一个模态窗口,用户可以输入指定的信息(例如发送消息)。我正试图以这种方式使用dialogContainer视图助手。
首先,将ZendX库包含在应用程序库文件夹中。
其次,在Bootstrap.php文件中的initViewHelper方法中包含以下行
“$ view-> addHelperPath('ZendX / JQuery / View / Helper /','ZendX_JQuery_View_Helper');”
第三,在layout.phtml
中添加以下条件启用js "<?php if($this->jQuery()->isEnabled()){
$this->jQuery()->setLocalPath($this->baseUrl()
.'/js/jquery/js/jquery-1.4.2.min.js')
->setUiLocalPath($this->baseUrl()
.'/js/jquery/js/jquery-ui-1.8.custom.min.js')
->addStylesheet($this->baseUrl()
.'/js/jquery/css/ui-lightness/jquery-ui-1.8.custom.css');
echo $this->jQuery();
}
?>"
第四,创建扩展ZendX_JQuery_Form的Application_Form_JQueryForm
"<?php
class Application_Form_JQueryForm extends ZendX_JQuery_Form
{
private $form;
public function init()
{
$this->form = $this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/index/index')
->setMethod('post');
$this->form->setDecorators(array(
'FormElements',
'Form',
array ('DialogContainer', array(
'id' => 'tabContainer',
'style' => 'width: 600px;',
'title' => 'Send a private message to Kalle',
'JQueryParams' => array(
'tabPosition' => 'top',
),
)),
));
$topic = new Zend_Form_Element_Text('topic');
$topic->setValue('topic')
->setRequired(true)
->setValidators(array('validators' => array(
'validator' => 'StringLength',
'options' => array(1,15)
)))
->setDecorators(array(
'ViewHelper',
'Description',
'Errors',
array('HtmlTag', array('tag' => 'dl'))));
$textarea = new Zend_Form_Element_Textarea('textarea');
$textarea->setValue('post a comment')
->setAttribs(array(
'rows' => 4,
'cols' => 20
))
->setRequired(true)
->setValidators(array('validators' => array(
'validator' => 'StringLength',
'options' => array(1,15)
)))
->setDecorators(array(
'ViewHelper',
'Description',
'Errors',
array('HtmlTag', array('tag' => 'dl'))));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Send your comment')
->setDecorators(array(
'ViewHelper',
'Description',
'Errors',
array('Description', array('escape' => false, 'tag' => 'span')),
array('HtmlTag', array('tag' => 'dl'))))
->setDescription('or <a href="/index/index/send/false">Cancel</a>');
$this->form->addElements(array($topic, $textarea, $submit));
}
}” 然后在控制器操作方法中实例化该表单,并在视图中调用。
对于我的问题,无论我尝试什么,为了例如设置,dialogContainer的宽度或任何其他参数(颜色,css,高度,等等),这是对于表单的JQueryForm的setDecorator部分,在视图中调用时,我似乎无法在生成的模式中得到任何更改,在正确的方向上的任何帮助将不胜感激
提前致谢,Kalle Johansson
答案 0 :(得分:0)
肯定是一个迟到的答案 - 但很多观点 - 所以我想回答。您要为模态设置的参数应该从JQueryParams数组中设置。所以 - 例如:
$this->form->setDecorators(array(
'FormElements',
'Form',
array ('DialogContainer', array(
'id' => 'tabContainer',
'style' => 'width: 600px;',
'title' => 'Send a private message to Kalle',
'JQueryParams' => array(
'tabPosition' => 'top',
'width' => '600',
'height' => '450'
),
)),
));
您可以在jQuery UI网站上找到这些参数选项。
LK