Adding model lines to forms dynamically - without calling controller

Good day guys!

I would like to be able to add models in the view without having to the call the controller as I would like to minimise the number of calls to server. Why should a call be made to the server using bandwidth and memory when the view is what we need to change without the need of doing processing at the server side? so Efficiency is what I am thinking about.

A solution I thought of is to have a text var with html elements to be appended to a div element on view, I tried using php inside but it never worked, I read that the only way I can get php to work is through ajax/pjax calls that to render a view.

What do you guys recommend in such cases? Do you have a better solution than the text variable in js to be appended to div?

Thanks in advance!

how do you use views without controller? and what’s so expensive? =)

Maybe this is the widget you are looking for ?

@ QuadroVal

Expensive and not expensive depends on the call itself and what you will send back… You definitely need to call the controller for the first render of the form but to add lines to what has been rendered (Post page load) I don’t think it is a good idea to send back all models and then add a model in the controller and send it back to the view… It is basically a waste of resources.

It is unnecessary use of server memory and network bandwidth… This should be somehow should be managed within the view itself… only post to server at the end of your form filling… to apply business logic and server side validation maybe that can not be done at client side…

@ Timmy, Thanks mate, will download it and give it a try…