L
L
LucasP2019-05-04 15:54:25
Yii
LucasP, 2019-05-04 15:54:25

Displaying ActiveForm fields?

There is a model and a form, on the form there is one dropdown with selection options (and each requires its own set of model fields). What can be done to solve it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-05-04
@webinar

JS (jQuery). We listen to the change event in the select, then several options:
- ajax request, getting the necessary form fields (html + js via ->renderAjax()
- the fields are already in a separate block, we just hide and show the blocks
- there is a config in the form of json, it contains field selectors, which should be shown when the option is selected.
There is also a simple, but not userFrandly option, when changing the select results in a get request with a parameter, which simply regenerates the page. But if there are problems with js, this option may turn out to be simple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question