I started to create a bunch of forms and was finally copying previous forms to have similar parts inside...
The forms only differ on a few fields but have common unchanged fieldsets such as personal data / address, ...

How about the option to provide template fieldsets to refer to in individual forms.
They should be marked differently and if one change them, all forms referring to them get updated.

Does this approach need some update on all forms using a specific template to be updated or is it just possible to implement on a field import? Is there some architecture conflict?

A great common sense of minimizing stupid duplication of similar elements.
I'm open for any opinion regarding this and waiting for answers prior to dive into the code.

Comments

quicksketch’s picture

I don't think such a "templating" system is likely in Webform. An an option, you can use the node_clone module to duplicate existing webforms and modify them. A patch has also been submitted for #298268: Clone across forms (D5&D6), but I doubt this feature will be added.

quicksketch’s picture

Status: Active » Closed (won't fix)
miro_dietiker’s picture

Title: template fieldsets to refer to instead of copy » inject components from a master template form
Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Closed (won't fix) » Active

We're currently working on a clean implementation of this original issue.
Cloning for us was/is no option. It is very common in our usecase to have shared parts of a form - such as a standard contact data (3 fields) + Further notice field.

The module will be able to
- Build a master form with a setting "This is a master/Template form".
- Users will be able to add a component "inject fields from master" to any form at any place.
- Fields don't get copied on injection. It's a remaining reference. They only get displayed on output or injected for interaction.

Based on this you will be able to "attach" all form components of a master form to any other form.
A resulting form might be a result of single fields plus several master template form parts.

quicksketch we'll have to decide if this feature is a separate project or could be part of webform itself.

miro_dietiker’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev

oops, we're working on 6.3 for the moment.

quicksketch’s picture

Status: Active » Closed (won't fix)

I'd prefer this functionality was external to Webform. If API changes are necessary (I don't think they would be for such functionality), please open issues for those changes.

miro_dietiker’s picture

Status: Closed (won't fix) » Active

Thanks for answer.
We ran into multiple possible solutions and each of them results in some issues regarding current webform functionality.

1. If we decide implementing a injection component and inject the component as subfields there are certain limitations:
- Injected page breaks won't work anymore (since the need to be real components)
- There might be some limitations with subfields... (unknown to me)

2. If we try to inject on main level we need further hooks that inject the components (on main level - not as subfields) right before display, but this state should never be considered for save...

3. Additionally we might save data in a referred form submission - so submitting a combined form (with a single injected part) might lead to two form submissions with reference instead of a single one.

Do you have any architectural input how to temporary inject foreign components including pagebreaks?

quicksketch’s picture

You can inject things in hook_nodeapi($op == 'load') and Webform will load them just fine. However you'd need to prevent these components from ever being edited or used in certain situations but not others. Webform has a full suite of hooks for handling components, but it's hard to just add things to the Webform without giving the components full functionality. If you have suggestions in this area I'm willing to hear them, but I'm really not interested in this functionality.

quicksketch’s picture

"This functionality" being the pseudo-component functionality needed for "master templates" etc.

quicksketch’s picture

Status: Active » Closed (won't fix)

Once again, please open new issues (referring to this one if necessary) for suggested API changes that are necessary for this to be done as an external module. This will not be added to Webform directly.