dongming8867 2017-09-28 15:19
浏览 33
已采纳

ZendFramework:将表单元素视图帮助器InputErrorClass更改为“has-error”

I use the FormRow View Helper in my forms which works fine except for the fact that, when the element has errors, it adds 'input-error' to the class.

Since I am using Bootstrap3, I would like to use the 'has-error' class for the input element.

Is there a easy way to set the default InputErrorClass to 'has-error' without creating my own plugins that would extend ForRow or FormInput?

The Zend\Form\View\Helper\FormRow class has a public function (setInputErrorClass) that sets the inputErrorClass property but I can't seem to be able to use it since FormRow is a plugin, unless I am missing something about ZF and PHP.

  • 写回答

1条回答 默认 最新

  • dongpinyao2203 2017-09-28 19:02
    关注

    I assume you are using in your view:

    $this->formRow($element);
    

    You can add before you use formRow:

    $this->formRow()->setInputErrorClass('has-error');
    

    or

    $this->formRow()->setInputErrorClass('has-error')->render($element);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败