D
D
Dmitry Sidorenko2015-09-15 15:10:41
Yii
Dmitry Sidorenko, 2015-09-15 15:10:41

How in the GII crud one to many generator in _form to display not input but radio with all associated values?

I'm trying to generate CRUD functionality for two tables through Gii.
After generating models and CRUD in the view, everything is displayed normally, but without taking into account dependencies. Those. in principle, I want to display in the “select” edit, and in it the names from the Manufacturers table (and “input” is displayed). And just for example, you need to hang a radio button. I can't find how to do it yet. I suspected that Yii2 Gii does this automatically.
How to make select, radio button generated in Gii CRUD or is it manual only?
PS in the product model, an association was generated for the Manufacturer

public function getIdManufacturer()
    {
        return $this->hasOne(YiiManufacturer::className(), ['id_manufacturer' => 'id_manufacturer']);
    }

But why should I? To pull out all the information on the manufacturer without your own SQL queries? How to use it when forming the form?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimon, 2015-09-15
@Glimor

this is not done automatically. You write by hand, for example:
and in the model (let's say Category) we write a method

public static function getStatusList() {
  $droptions = Status::find()->asArray()->all();
return Arrayhelper::map($droptions, '_id', 'name');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question