Answer the question
In order to leave comments, you need to log in
How to store information about fields used in forms?
As the project develops, it begins to acquire a different number of forms (authorizations, adding / deleting model material, etc.). Already now I understand that there can be a problem when you need to add a field to a form that is used in several places for example. The idea arose to create, for example, a config file in which to write all the fields for each specific form, for example:
[ type => "text", "name" => 'post_title', "lable" => "Заголовок поста", "required" => true]
Answer the question
In order to leave comments, you need to log in
Write a form builder. Types and names of fields store in the corresponding table of a DB.
The documentation has some solutions to this problem.
You can use components, subview, sections. Accordingly, you can cut your layout as you like and reuse it.
And regarding the dynamic substitution of fields in forms, what profit will you get?
Probably it will be according to DRY, (Don't Repeat Yourself) only there is a downside:
- the form is also validation, you will have to solve this and that somehow
- you will bring your own developments into the project, which will only complicate its support by other people and you .
- Spend extra time on development
Vzvest everything - the best is the enemy of the good.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question