简体   繁体   English

yii2:radioList必须为字符串

[英]yii2:radioList must be a string

I have this field in my _form.php 我的_form.php中有此字段

<?= $form->field($model, 'delivered')->radioList
([ 'delivered' => 'Delivered', 'part' => 'Partly Delivered']) ?>

I am getting the error, when I am selecting the radio-box Delivered I am getting the error - 我收到错误消息,当我选择“已交付”单选框时,我收到了错误消息-

delivered must be a string 传递的必须是字符串

I can't make out what is wrong in the syntax. 我无法找出语法上的错误。

Validation rule in the model is like: 模型中的验证规则如下:

public function rules()
    {
        return [
            [['ipd_patient_id', 'room_name'], 'integer'],
            [['request_time', 'issue_time'], 'safe'],
            [['general_regn_no'], 'string', 'max' => 15],
            [['patient_name'], 'string', 'max' => 50],
            [['delivered'], 'string', 'max' => 20]
        ];
    }

Thanks. 谢谢。

There is no problem with your syntax for radioList . 您的radioList语法没有问题。 The only problem is for your validation rules. 唯一的问题是您的验证规则。 You have a rule for delivered which does not match values ( delivered , part ). 您有一个与值不匹配的delivered规则( deliveredpart )。 You need to check your model's rules. 您需要检查模型的规则。

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

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