Hi,
I am trying to create custom components to get tabsets and tabpages in a web form. In order to render the tabs it was necessary to make the dragging behaviour of tabset/tabpage similar to fieldset or pagebreak. This can be done by modifying code around line 229 in webform.components.inc:
if ($component['type'] != 'fieldset' && $component['type'] != 'pagebreak'
&& $component['type'] != 'tabset' && $component['type'] != 'tabpage' // this line was added
) {
$row_class .= ' tabledrag-leaf';
}
Would it be possible to add a parameter to specify the drag/group behaviour in hook_webform_component_info in order to not needing to patch the webform code?
In case anyone is interested in similar functionalty, the code is attached. It depends on the Tabs module.
Thanks,
John
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | webform_group_feature.patch | 5.94 KB | quicksketch |
| #5 | webform.patch | 3.54 KB | jpulles |
| #2 | webform.patch | 3.58 KB | jpulles |
| webform_tabs.zip | 2.78 KB | jpulles |
Comments
Comment #1
quicksketchThis sounds like a great idea. We should simply extend hook_webform_component_info() so that it returns which components are "groups". This currently includes pagebreaks and fieldsets, but it would open the door to a component like a tabset also. By the way, what's the need for a "tabpage"? This isn't the same as a pagebreak is it? Seems like you'd want to group them as "tabgroup" (or tabset) and "tab".
Comment #2
jpulles commentedIt works great with the webform module with only minor modifications. 'tabset' and 'tabpage' are the names used in the Tabs module. It's not the same as a pagebreak because on a pagebreak the validation is executed, even when returning to a previous page; when using (javascript) tabs the validation is only executed on submit.
I included the patch I am using now on the webform module, with a function named webform_component_type_is_group(); 'pagebreak' is not in it by the way, because it is only used in the places where the type was compared with 'fieldset'.
Comment #3
jpulles commentedBest names are probably 'tabset' and 'tab'.
Comment #4
quicksketchInstead of making a new function
webform_component_type_is_group(), what I meant was you should add a new property to 'page' and 'fieldset' components in webform_webform_component_info(), called "group". Then you can do the same thing with your tab and tabset components, in your modules hook_webform_component_info(), then you can use the existing functionwebform_component_feature($component['type'], 'group')to check if a component should be treated like a group or not.We might still build in an exception for 'pagebreak' if necessary, since it's clearly a special use-case throughout webform.
Comment #5
jpulles commentedThanks, I didn't realise that the function webform_component_feature could be used for this. Please find attached a patch on 6.x-3.0-beta2, although the version number in the patch is from our internal svn system.
Comment #6
quicksketchExcellent patch. I found 3 more places where we need to replace hard coded 'fieldset' references (in the theming of e-mails). I also set a default for group = FALSE in webform_component_feature(), and updated our documentation in webform_hooks.php. Everything else looks great! Committed the attached version.