【问题标题】:Auto fill radio button in volt template without using model在不使用模型的情况下自动填充电压模板中的单选按钮
【发布时间】:2023-03-24 19:03:01
【问题描述】:

我使用下面的代码在 volt 文件中渲染了表单的元素。我想自动填充默认单选按钮。

<div class="form-group" >
    <div><label>Gender *:</label>
    <label class="radio-inline popup-gender">{{ element }}{{ element.label()}}:</label>
    </div>

【问题讨论】:

  • 您找到解决方案了吗?
  • 不......我做了不同的......

标签: phalcon volt


【解决方案1】:

如果您使用 PHP 来准备表单:

$radio = new Radio('my_radio', ['id' => null, 'value' => 'one']);
$radio->setDefault('one');
$form->add($radio);
$radio = new Radio('my_radio', ['id' => null, 'value' => 'two']);
$form->add($radio);

如果您使用的是 Volt:

{{ set_default('my_radio', 'one') }}
{{ radio_field('my_radio', ['id' => null, 'value' => 'one']) }}
{{ radio_field('my_radio', ['id' => null, 'value' => 'two']) }}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多