2
爲了顯示的選項給用戶的列表中,我用下面的代碼:如何警予使用單選1
public function getData($property)
{
$data=array(
'membership_fee' => array(
'Large Company & Organisation',
'Medium Company & Organisation',
'Small Company & Organisation ',
'Mini- Company & Organisation',
'Individual Membership ',
'Large Company & Organisation ',
'Medium Company & Organisation ',
'Small Company & Organisation',
'Mini- Company & Organisation ',
'Individual Membership ',
),
);
return $data[$property];
}
和
<div class="form-group">
<?= $form->labelEx($model, 'membership_fee', array('class' => 'col-xs-12 col-sm-4 control-label')) ?>
<div class="col-xs-12 col-sm-8">
<?= $form->radioButtonList($model, 'membership_fee', $model->getData('membership_fee'), array(
'template' => '<div class="radio col-xs-12 col-sm-6">{beginLabel}{input}{label}{endLabel}</div>',
'separator' => '',
)); ?>
<?= $form->error($model, 'membership_fee') ?>
</div>
</div>
但是,這些代碼保存數據數字的形式(例如,如果用戶選擇大型公司並將其保存到數據庫中爲0,或者如果用戶選擇miduim公司並將其保存到數據庫爲1)。我需要將數據保存到數據庫,因爲選擇標題不是數字。我該怎麼做?
很高興幫助你phpdev :) :) –