I wonder if it´s possible to use the form framework for domain model CRUD forms?
Looking at the documentation and searching through the code this seems currently impossible.
I think it would be nice, if all forms inside an application can use the same templates, regardless if they are standalone or bound to a model…
you are right, currently this is not possible in a good way. We experimented a bit with this in TYPO3.Expose one or two years ago, but unfortunately this did not work out really well…
So, if you have some solution on how this could be approached, this would be very cool to see
I´m really new to Flow so I do not have the big picture of the internals.
But I see form:form viewhelper allready extends the fluid:form viewhelper. So maybe you could implement another FormDefinition class which can be bound to a domain model class (or a concrete model object?) . Then you could automatically build the form definition from the given model properties and propterty validators and then pass the model object to the form (or pass it into the form viewhelper using the FormRuntime)? Maybe? I don´t know
Of course it should also be possible to modify the form action and the automatically built FormDefinition…
This question made me think about the Django admin generator, that can build some automatic interface for your models … from my POV, it’s fast and easy for beginner but does not match real application needs. So for me spending tons of time building something that “automagically” create the backend of your application is a bit of a no go. This kind of tools need to be so flexible and configurable … it’s pretty impossible to build something useful for all use case (multi step, correct validation, …) with creating a monster and the Expose project show exactly that, yes it’s flexible but harder to use than writing some raw fluid template.
I’m more in favor of something like Symfony do:
This is just a kickstarter for the form configuration, based on your model. If we can do that and provide some generic controller for the CRUD operations (can/must be part of the API project) that should be enough. People can iterate over the the generated configuration.
Did we need to build a YAML form definition and something more based on raw fluid … I don’t know. In our projet we use more raw fluid, but we never try to replace this with the Form framework and that should work fine I think.
There was already a state of Expose quite far along that was based on
TYPO3.TypoScript and TYPO3.Form. In the end i abandoned that path because of the reasons i wrote about a while ago:
There is a currently pretty stable running version of expose in github+packagist called Flowpack.Expose which is built quite close to the basic ideas described in that gist document, aside from some specifics and different naming schemes.
My main thought was that if I decide to use TYPO3.Form in my application, it would be nice to share the same markup/templates between all different forms, so I don´t have any duplicate code. But I understand that this would add much more complexity…
I like the idea of the f:form.field viewhelper mentioned by @mneuhaus as this would solve this perfectly. If I find some time, I will have a look into this…