在一行上显示 Zend_Form_Element_Radio

发布于 2024-07-28 23:02:01 字数 345 浏览 2 评论 0原文

Zend Framework 中的单选按钮显示在一列中(每行一个选项)。 如何从标记中删除 br 标签,以便所有单选选项保留在一行中?

我的装饰者是:

private $radioDecorators = array(
    'Label',
    'ViewHelper',
    array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'radio')),
    array(array('row' => 'HtmlTag'), array('tag' => 'li')),
);

The radio buttons in Zend Framework are displayed in a column (one option per line). How can I remove the br tag from the markup so that all radio options stay in one line?

My decorators are:

private $radioDecorators = array(
    'Label',
    'ViewHelper',
    array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'radio')),
    array(array('row' => 'HtmlTag'), array('tag' => 'li')),
);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

第七度阳光i 2024-08-04 23:02:01

您需要在 Zend_Form_Element_Radio 对象上调用 setSeparator 方法,并传递它“”。 这是此处的示例

<?php     

class CustomForm extends Zend_Form
{
  public function init()
  {
    $this->setMethod('post');
    $this->setAction('user/process');
    $gender = new Zend_Form_Element_Radio('gender');
    $gender->setLabel('Gender:')
      ->addMultiOptions(array(
        'male' => 'Male',
        'female' => 'Female'
      ))
      ->setSeparator('');
  }
}

You need to call the setSeparator method on the Zend_Form_Element_Radio object, passing it ''. Here's an example from here:

<?php     

class CustomForm extends Zend_Form
{
  public function init()
  {
    $this->setMethod('post');
    $this->setAction('user/process');
    $gender = new Zend_Form_Element_Radio('gender');
    $gender->setLabel('Gender:')
      ->addMultiOptions(array(
        'male' => 'Male',
        'female' => 'Female'
      ))
      ->setSeparator('');
  }
}
丢了幸福的猪 2024-08-04 23:02:01

使用如下选项

array("listsep" => ' ')

这将通过 ' ' 进行单选分隔

use options as follows

array("listsep" => ' ')

This will make radio seperation by ' '

︶ ̄淡然 2024-08-04 23:02:01

使用 Zend_Form_Element_Radio::setSeparator($separator) 方法:

例如

$element->setSeparator('');

分隔符默认为 '\<\br />' 如 getSeparator() 所示。

Use the Zend_Form_Element_Radio::setSeparator($separator) method:

e.g.

$element->setSeparator('');

The separator defaults to '\<\br />' as shown by getSeparator().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文