N
N
Nikolai Novosad2015-01-02 19:34:21
Yii
Nikolai Novosad, 2015-01-02 19:34:21

Yii2 Display related data in dropDownList?

Hello.
There are 3 tables: Catalog(category), Section(section), Product(product). Section is related to Catalog and Product is related to Section.
All generated through gii. When adding a new Product, I did this:

$form->field($model, 'section_id')->dropDownList(ArrayHelper::map(
        Section::find()->all(), 'id_section', 'section_name'
    ));

to be able to select an available section. Those. 'Asus' or 'Lenovo'. But lenovo can be both a laptop and a monitor.
You need to make it display 'Laptop->Lenovo' or 'Printing equipment->MFP' or 'Monitor->Lenovo'.
Can you please tell me how to implement this?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Natarov, 2015-01-02
@HanDroid

That's it.
Everything is the same, only the names are different.
See how the catalog is made on the same outlet. There the implementation is as follows:
- Section (for example Computers)
-> ** see below
->Category (for example Monitors, Processors, mice, keyboards)
-> Then the products themselves.
(Optional!) You can also add a sub-category between the section and the category, for example, if you want to separate computers by class (Gaming, laptops, office, etc.) If you have a brand, you can display by brand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question