I'm happy to announce the Subform Element module 1.2. It's intended to make developers life easier. It allows you to reuse existing forms inside your own forms, e.g. just embed a fully working node form. The notable changes since the 1.0 release are some new form element properties, first of all the new data separation feature!
data separationWithout data separation the values of each form will be transmitted as usual in the $_POST array. So if both forms use a field with the same name, e.g. 'title' both will end up in $_POST['title'], so obviously the latter title will overwrite the first one. This was an issue if you tried to put two node forms into one using subform elements. Subform Element 1.2 has #data_separation turned on per default, which let's subform element prefix all the elements name of a subform. So the data ends up in e.g. $_POST[$subform_id]['title'], where $subform_id is the id of your subform. Then the data is separated and you can safely combine forms with overlapping element names. Have a look at this handbook page, it shows how easy it is now to merge two node forms into one.
subform customizationSo now it's easy to reuse every form by using the subform element. What's missing is an easy way to customize the subform, without modifying the original form. For this subform element 1.2 comes with two new optional properties:
- #subform_after_build: An optional array of after_build functions for the subform.
- #extra_form: An optional array of further form elements that will be added to the subform.