Pawan
Pawan

Reputation: 3864

yii2:radioList must be a string

I have this field in my _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.

Upvotes: 0

Views: 1624

Answers (1)

Ali MasudianPour
Ali MasudianPour

Reputation: 14459

There is no problem with your syntax for radioList. The only problem is for your validation rules. You have a rule for delivered which does not match values (delivered,part). You need to check your model's rules.

Upvotes: 1

Related Questions