Spin-off from #1499596-96: Introduce a basic entity form controller:

I noticed that due to $controller->form_state the form state gets serialized *into itself* when it is cached. I've discussed that with plach and we agreed to remove $controller->form_state for now and just pass it on to respective methods always. We may want to simplify the getEntity() calls to do not require the passed on form-state again in the follow-up where we fix the controller being still duplicated to $form and $form_state.

To be completed.

Comments

fago’s picture

Right now the controller gets into $form when it is assigned as callback, e.g. when assigned as #submit handler. Then it also in $form_state['controller'], however both arrays get serialized independently of each other, what means we'll get two controller instances after cache retrieveal.

That's something we want to fix. Right now, this is no problem as the controller contains no state though, but that might change.

sun’s picture

Hm. I don't quite get it.

Why do we store the controller in $form?

$form_state['build_info']['callback'] = array($controller, 'build');

It looks like we could simply replace that?

$form_state['build_info']['callback'] = array(get_class($controller), 'build');

For a #cache'd form, the callback is not re-invoked on subsequent requests. For non-#cache'd forms it is.

To me this actually looks like as if $controller should be a $factory here...?

fago’s picture

The controller also adds itself to button handles, e.g. $form['button']['#submit'] which are executed on cached forms.