In my application I have an feature that needs to reload whole form on an a update action. I thought I can just make an AJAX request to special action and in that action call the original action that generate the form but based on diffrent parameters.
How can I respond to JavaScript request with an HTML output of diffrent action?
I’ve tried something like this:
if ($request->isXmlHttpRequest()) {
return $this->editPageContentAction($responseObjects[0]->getId());
}
but it does not work (Controller must return response).
The easiest way to describe what I want to achive is:
- I have a form that edits an entity with a select “copy content from another entity” with list of other enteties
- When user selects another entity I want to reload with AJAX the form Im currently on but populated with selected Entity
- I dont want to redirect user to edit entity form with selected entity, I want to just prefill new entity form with data from existing entity, so I though I could use action that allready exists to editing this entity.
- Javascript function will just update the html with new form.
When your editPageContentAction method return the html output.