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

Comments

quicksketch’s picture

This 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".

jpulles’s picture

StatusFileSize
new3.58 KB

It 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'.

jpulles’s picture

Best names are probably 'tabset' and 'tab'.

quicksketch’s picture

Instead 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 function webform_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.

jpulles’s picture

Status: Active » Needs review
StatusFileSize
new3.54 KB

Thanks, 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.

quicksketch’s picture

Version: 6.x-3.0-beta2 » 7.x-3.0-beta4
Status: Needs review » Fixed
StatusFileSize
new5.94 KB

Excellent 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.