E
E
EVOSandru62017-08-03 18:59:05
Yii
EVOSandru6, 2017-08-03 18:59:05

How in Yii2 to organize the insertion of a form and a handler for it anywhere on the site by the admin?

Good afternoon!
There is such a task - you need to make a form generator on the site, which is already unsafe, I think, because it needs to be validated somehow, perhaps you need to write some kind of validation rule in the records of the form elements and check it using JS . If anyone can suggest a solution, I'd be grateful. But this is not the main problem.
In order to place a form anywhere on the site and change its location, as I understand it, it is possible, as an option, to set markers into which, when rendering the page, insert or not insert a certain form (almost all postal forms).
I'm more interested in how to make a handler for such dynamic forms and where to store it? Just beforeAction
comes to mindin some base controller. Please advise who did this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-08-04
@EVOSandru6

There is such a task - you need to make a form generator on the site, which is already unsafe, I think, because it needs to be validated somehow, it may be necessary to prescribe some kind of validation rule in the records of the form elements and check with JS.

You made a fool of yourself ... this functionality can be implemented using a standard dynamic model and avoid a bunch of crap
Of course, markers are also possible, but this is somehow not obvious + there will be an overhead to search for these markers .... it’s better to make some kind of widget that will render the desired form (for example, by its identifier)
it is better to make some kind of sdandalone action that will receive data, load it into a dynamic form and do the necessary actions with it

I
Igor Vasiliev, 2017-08-04
@Isolution666

Hello. )))
If you have used the gii generator in Yii2, then you probably know that you can generate any forms there. So, if you personally need it, to quickly implement the creation of forms, then this solution is right under your nose, if you want it for users, it’s not entirely clear what the salt is, of course, then take the functionality from the box of your framework, there already everything is thought out and implemented. If this is a CMS system, then be prepared for the fact that the functionality should be clear to the most finished office plankton, or a newly-minted manager, and even a retired old woman, otherwise all the functionality, work, and time spent will be in vain. Which is more frustrating than non-working code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question