【问题标题】:How to add dynamic radio buttons in form?如何在表单中添加动态单选按钮?
【发布时间】:2023-03-15 20:20:01
【问题描述】:

我需要帮助。如何在现有表单中添加单选按钮? 我试着这样做:

$metodadeplata = array('ramburs','ordindeplata');

   foreach($metodedeplata as $metoda){

        $radio = new Element\Radio('metodedeplata');
        $radio->setValue($metoda);
        $checkoutform->add($radio);

    }

,但它只取最后一个值。 $checkoutform 是已经声明的表单。

【问题讨论】:

    标签: php forms zend-framework2 radio-button


    【解决方案1】:

    根据the doc,这不是无线电元素的工作方式:

    $radio = new Element\Radio('metodedeplata');
    $radio->setLabel('Label for metodedeplata');
    $radio->setValueOptions([
        '0' => 'ramburs',
        '1' => 'ordindeplata',
    ]);
    
    $checkoutform->add($radio);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-04
      • 1970-01-01
      • 2017-11-30
      • 2010-10-02
      • 2020-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多