T
T
tempick2020-09-30 22:55:11
Yii
tempick, 2020-09-30 22:55:11

How to properly validate a value from two form elements?

There is yii2 + mysql. There is a table with products and the corresponding model (activeRecord) and form (ActiveForm). There is a field indicating the id of the product category. At the moment, in the form of adding a product, this is done like this:
Two selects with a category and a subcategory, when the user selects a category and a subcategory (the select with subcategories is updated via ajax when the value of the first list changes), then the js script (written manually) receives the id of the selected category and pushes it into input hidden which is created with ActiveForm and this value is already validated in yii2. The question is: how correct is this, and what to do if, for example, js is disabled by the user?
Those. Problems and that the field with a category consists of two fields.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question