标签: zend-form

Zend中的Action View Helper - 可以解决吗?

我正在构建一个我希望用作"标签式浏览"功能的界面.这些选项卡中的每一个都已编写为操作,选项卡式界面可作为各个选项卡的链接.我决定尝试为这个控制器编写"索引"页面 - 将所有选项卡的内容放入隐藏的div并使用jQuery在它们之间交换,但是一旦我开始使用动作视图助手 - 我遇到了很多人说这是不好的做法.(见本文)

其中一些操作会构建表单 - 从模型中获取一些数据等以显示.我希望每个动作都能继续自行运行(一些解析形式).

浏览到/ item应该为您提供选项卡式菜单,以及隐藏标记中所有div的内容 - 其中/ item/tab2是特定操作(例如表单提交).

另一个复杂/警告 - 如果用户无权访问该"选项卡",某些操作将抛出Access Exceptions.我不想两次将访问检查构建到系统中(因此显示一个包含空内容的选项卡).

我只想弄清楚处理这类事情的最佳做法是什么,我认为动作助手可能就是这样.如果我尝试使用View Helpers - 我开始想知道这是否是组装Zend_Form的正确位置.

有没有人对"正确"的方法有任何建议,不使用Zend_View_Helper_Action

php model-view-controller zend-framework zend-form

10
推荐指数
1
解决办法
6661
查看次数

Zend_Framework装饰器在div中包装Label和ViewHelper

我是新手,zend装饰malarchy,但我有两个重要问题,我无法理解.问题一之后是一些例子

$decorate = array(
    array('ViewHelper'),
    array('Description'),
    array('Errors', array('class'=>'error')),
    array('Label', array('tag'=>'div', 'separator'=>' ')),
    array('HtmlTag', array('tag' => 'li', 'class'=>'element')),
);

...

$name = new Zend_Form_Element_Text('title');
$name->setLabel('Title')
    ->setDescription("No --- way");

$name->setDecorator($decorate);
Run Code Online (Sandbox Code Playgroud)

哪个输出

<li class="element">
    <label for="title" class="required">Title</label> 
    <input type="text" name="title" id="title" value="">
    <p class="hint">No --- way</p>
    <ul class="error">
        <li>Value is required and can't be empty</li>
    </ul>
</li>
Run Code Online (Sandbox Code Playgroud)

问题#1

我如何包装labelinput围绕div标签?所以输出如下:

<li class="element">
    <div>
        <label for="title" class="required">Title</label> 
        <input type="text" name="title" id="title" value="">
    </div>
    <p class="hint">No --- way</p>
    <ul class="error">
        <li>Value is …
Run Code Online (Sandbox Code Playgroud)

zend-framework zend-form zend-decorators

10
推荐指数
1
解决办法
7524
查看次数

Zend Framework 2中的MultiSelect

Zend Framework 1.12中有一个Zend_Form_Element_Multiselect.如何在Zend Framework 2.0中实现相同的结果?我只看到Zend\Form\Element\MultiCheckbox和Zend\Form\Element\Select

php zend-form multi-select zend-framework2

10
推荐指数
2
解决办法
1万
查看次数

在Zend_Form中,如何避免Zend_Validate_Email产生多个错误?

我正在构建一个ZendFramework应用程序,它作为一个登录表单,要求提供电子邮件地址和密码 - 在使用登录尝试访问数据库之前验证电子邮件地址似乎是有意义的,因为无效的电子邮件永远不会导致有效命中.Zend_Validate_EmailAddress似乎是正确的方法,但我遇到了生成多个错误的问题(在底部的问题,在代码之后).

我的表格目前有以下内容

//WPMail_Form_Login::init()
$email = $this->addElement('text', 'email', array(
    'label'=>'Email',
    'required'=>true,
    'filters'=>array('stringtrim'),
    'validators'=>array(array('emailaddress', true, array(
        'messages'=>array(
            'emailAddressInvalidHostname'=>'Your email address is invalid',
            'emailAddressInvalidFormat'=>'Your email address is invalid',
            '...'=>'(repeat for all message templates)'
        )
    ))),
));
Run Code Online (Sandbox Code Playgroud)

在控制器中我直接将表单传递给视图:

// WPMail_AuthController::loginAction()
$this->view->form = $form;
Run Code Online (Sandbox Code Playgroud)

在视图中,它直接回应:

// views/scripts/auth/login.phtml
<?php echo $this->form ?>
Run Code Online (Sandbox Code Playgroud)

结果目前是这样的:

- Your email address is invalid
- 'asda!!!' does not match the expected structure for a DNS hostname
- 'asda!!!' does not appear to be a valid local network name
Run Code Online (Sandbox Code Playgroud)

我想要知道的是:是否可以配置Zend …

php zend-framework zend-form zend-validate

9
推荐指数
1
解决办法
1988
查看次数

如何禁用Zend_Form_Element_Radio中的各个选项

是否可以禁用单个选项Zend_Form_Element_Radio?也就是说,我想添加disabled="disabled"某些输入标签.

Zend Framework是否包含此功能?或者还有另一种方法来实现这一目标吗?

php zend-framework zend-form zend-form-element

9
推荐指数
1
解决办法
2772
查看次数

Zend Date - 日差

我有以下代码行

$day1 = new Zend_Date('2010-03-01', 'YYYY-mm-dd');
$day2 = new Zend_Date('2010-03-05', 'YYYY-mm-dd');
$dateDiff = $day2->getDate()->get(Zend_Date::TIMESTAMP) - $day1->getDate()->get(Zend_Date::TIMESTAMP);
$days = floor((($dateDiff / 60) / 60) / 24);
return  $days;  
Run Code Online (Sandbox Code Playgroud)

这将返回4

但如果给了

$day1 = new Zend_Date('2010-02-28', 'YYYY-mm-dd');
$day2 = new Zend_Date('2010-03-01', 'YYYY-mm-dd');
$dateDiff = $day2->getDate()->get(Zend_Date::TIMESTAMP) - $day1->getDate()->get(Zend_Date::TIMESTAMP);
$days = floor((($dateDiff / 60) / 60) / 24);
return  $days; 
Run Code Online (Sandbox Code Playgroud)

它将返回-27 ..我将如何得到正确的答案

zend-framework zend-form zend-date

9
推荐指数
2
解决办法
2万
查看次数

如何使用Zend表单描述添加自定义HTML标记

考虑我想展示

复选框,复选框标签和之后的图像.

如何使用Zend Engine Form创建相同的视图

我尝试如下

    $this->addElement(
            'Checkbox',
            "$key",
            array(
             'label'=>$value,
                'checkedValue' => "$key",
                'uncheckedValue' => '',
                'checked' => true,
             'disabled' => false,
          )
        );

     $element = $this->getElement($key);         


       $element->setDecorators(
   array(
     'ViewHelper',
     array('Label', array('tag' => 'dt', 'class'=>'hidden')),
     array('Description',array('escape'=>false,'tag'=>' span')), //escape false because I want html output
    )
   );

     $element->setDescription('<img name="help_'.$key.'" id="help_'.$key.'" src="/application/modules/User/externals/images/what-is-this.gif"/>');

$element->setDescription('<img name="help_'.$key.'" id="help_'.$key.'" src="/application/modules/User/externals/images/what-is-this.gif"/>');
Run Code Online (Sandbox Code Playgroud)

但显示复选框,描述图像和复选框标签为上标.

请帮忙

php zend-framework zend-form

9
推荐指数
2
解决办法
9329
查看次数

自定义zend_form Captcha输出?

我在我的zend_form中使用验证码.

$captcha_element = new Zend_Form_Element_Captcha(
    'captcha',
    array('label' => 'Write the chars to the field',
        'captcha' => array(
            'captcha' => 'Image',
            'wordLen' => 6,
            'timeout' => 300,
            'font' => DOC_ROOT . '/data/fonts/Vera.ttf',
            'imgDir' => $imagedir,
            'imgUrl' => $umageurl
        )
    )
);
Run Code Online (Sandbox Code Playgroud)

这会产生:

<dt id="captcha-input-label">
    <label for="captcha-input" class="required">Write the chars to the field</label>
</dt>

<dd id="captcha-element">
    <img width="200" height="50" alt="" src="http://sitename.com/captcha/09dd951939c6cdf7fa28f2b7d322ea95.png">
    <input type="hidden" name="captcha[id]" value="09dd951939c6cdf7fa28f2b7d322ea95" id="captcha-id">
    <input type="text" name="captcha[input]" id="captcha-input" value="">
</dd>
Run Code Online (Sandbox Code Playgroud)

然而. - 我需要跟随(captcha元素分别包含在一些标签中):

<dt id="captcha-input-label">
    <label for="captcha-input" class="required">Write the chars …
Run Code Online (Sandbox Code Playgroud)

zend-framework zend-form zend-form-element

9
推荐指数
1
解决办法
4078
查看次数

在Zend Form元素上使用多个PregReplace过滤器

我希望能够在单个Zend Form元素上添加多个PregReplace过滤器.我可以使用以下代码添加一个PregReplace过滤器:

$word = new Zend_Form_Element_Text('word');
$word->addFilter('PregReplace', array(
        'match' => '/bob/', 
        'replace' => 'john'
    ));
$this->addElement($word);
Run Code Online (Sandbox Code Playgroud)

我试过了

$word = new Zend_Form_Element_Text('word');
$word->addFilter('PregReplace', array(
        'match' => '/bob/', 
        'replace' => 'john'
    ));
$word->addFilter('PregReplace', array(
        'match' => '/sam/', 
        'replace' => 'dave'
    ));
$this->addElement($word);    
Run Code Online (Sandbox Code Playgroud)

但这仅仅意味着第二个过滤器工作.

如何添加多个PregReplace过滤器?

php zend-framework zend-form zend-filter

9
推荐指数
2
解决办法
3334
查看次数

如何以zend形式取​​消元素

我有一种形式,我有很多元素.我在许多地方使用表格.我有一个元素,file那就是:

$file= new Zend_Form_Element_File('merchantLogo');
        $file->setDestination("application_data/merchant/logo/original/");
        $file->addValidator('Count', false, 1);
        $file->addValidator('Extension', false, 'jpg,png,gif,jpeg');
        $file->setDecorators(array('ViewHelper','Errors'));
Run Code Online (Sandbox Code Playgroud)

现在,我想问一下,我怎样才能取消这种形式的任何元素.我想要这个,因为虽然在我的一个动作上我没有使用这个元素,但是这个元素正在创造问题.那么如何取消任何元素呢?

zend-framework zend-form zend-form-element

8
推荐指数
1
解决办法
1万
查看次数