[英]How would I format Zend_Form_Element_Radio so the label comes after the input
I have been trying to implement the solution in an earlier version of this question at: 我一直在尝试在以下问题的早期版本中实现该解决方案:
How would I format Zend_Form_Element_Radio so the label follows the input? 如何设置Zend_Form_Element_Radio的格式,以便标签跟随输入?
By creating an extended helper MyLib_View_Helper_FormRadio
but must be missing something obvious with this! 通过创建扩展的帮助器
MyLib_View_Helper_FormRadio
但是必须缺少一些明显的东西!
My question is how do I get Zend_Form_Element_Radio()
to use this now instead of the version of the helper in Zend_View_Helper_FormRadio
? 我的问题是如何让
Zend_Form_Element_Radio()
立即使用它而不是Zend_View_Helper_FormRadio
中的帮助程序版本?
I thought initially that this was done by creating the element with 我最初认为这是通过创建带有
$radio = new MyLib_View_Helper_FormRadio();
but realised its not. 但意识到它不是。
Changing the way the label and input are ordered in the Zend_View_Helper_FormRadio.php
does the trick but I realise that the Zend files should not be altered. 更改
Zend_View_Helper_FormRadio.php
中标签和输入的排序方式可以解决问题,但是我意识到Zend文件不应更改。
If anyone can help me with t his I would be very grateful! 如果有人可以帮助我,我将不胜感激!
In your MyLib_View_Helper_FormRadio
class, you have a method, like this (it's an example): 在
MyLib_View_Helper_FormRadio
类中,您有一个像这样的方法(这是一个示例):
public function formRadioCustom($name, $value = null, $attribs = null,
$options = null, $listsep = "<br />\n"){...}
So to call it instead of formRadio
of Zend_View_Helper_FormRadio
, if I'm not mistaken, you have to do: 因此,要调用它而不是
Zend_View_Helper_FormRadio
的formRadio
,如果我没记错的话,您必须这样做:
$element->addDecorators(array(array('ViewHelper',array('helper' => 'formRadioCustom'))));
And in your bootstrap add a method to add helper like this: 然后在您的引导程序中添加一个添加辅助程序的方法,如下所示:
protected function _initViewHelpers() {
$view = new Zend_View();
$view->->addHelperPath('MyLib/View/Helper/', 'MyLib_View_Helper');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.