简体   繁体   English

Zend Form单选按钮格式问题

[英]Zend Form Radio Button format problem

I have a problem with the radio element in Zend_Form. 我在Zend_Form中的单选元素有问题。

I have a decorator for the form, it's this:" 我有表格的装饰器,就是这样:“

$this->setElementDecorators(array(
                   'Label',
                   'ViewHelper',
                   'Errors',
                   array('HtmlTag', array('tag' => 'div', 'class' => 'clearfix')),
               ));

It works for all elements in the form except the radiobuttons. 它适用于表单中除单选按钮以外的所有元素。 After some research I found out that the input element is being placed inside the label tags, and the rest of the form has only the text in the setLabel method. 经过一些研究,我发现输入元素被放置在标签标签中,而表单的其余部分在setLabel方法中仅包含文本。

Is there a way to get it out of there because this is ruining my layout and I can't figure out how to do this the correct way. 有没有一种方法可以解决这个问题,因为这破坏了我的布局,我无法弄清楚如何正确地进行操作。

Welcome to ZF Decorators, get a helmet. 欢迎使用ZF Decorators,戴上头盔。 I find them useless, bad, rubbish and pretty uninviting to anyone wanting to start using ZF. 我发现它们对想要开始使用ZF的任何人都是无用的,不好的,垃圾的,并且非常诱人。

But, get into them! 但是,进入他们! Write your own , override the default one for Radio Buttons and make it work for you. 编写自己的,覆盖单选按钮的默认按钮,使其适合您。 Without this knowledge of ZF Decorators you will always be battling with the layout of forms or resorting to jQuery to reposition elements because the ZF Decorators didn't work as they wanted. 没有ZF Decorators的这些知识,您将总是在争夺表单的布局或使用jQuery来重新定位元素,因为ZF Decorators并没有按照他们的意愿工作。

In short, read the docs, write your own and start enjoying them. 简而言之,请阅读文档,编写自己的文档,然后开始使用它们。

you can change it in ZendRadio.php. 您可以在ZendRadio.php中进行更改。 Go to line 159 and change it to what ever you like. 转到第159行,并将其更改为您喜欢的内容。

One solution is to create your own version of Zend_View_Helper_FormRadio . 一种解决方案是创建自己的Zend_View_Helper_FormRadio版本。 Call it My_View_Helper_FormRadio and add your custom prefix path to the view (this can be done via your config file). 将其My_View_Helper_FormRadio并将您的自定义前缀路径添加到视图中(可以通过您的配置文件来完成)。

Then you will have complete control over the internal rendering (from the point of the ViewScript decorator). 然后,您将完全控制内部渲染(从ViewScript装饰器的角度ViewScript )。

If you provide an example of how you want the markup to render, I can elaborate or suggest an alternative. 如果您提供了有关如何呈现标记的示例,则可以详细说明或提出替代方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM