Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Render form actions as webform element #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions webform_submit_button.module
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,11 @@ function webform_submit_button_form_alter(&$form, &$form_state, $form_id) {

if ($current_component_type == 'submit_button') {

// Get the weight of the user's submit button component.
$current_weight = $value['#webform_component']['weight'];

// Apply the weight to the actual webform submit button.
$actions = $form['actions'];
$actions['#weight'] = $current_weight;

// Move the webform submit button into the position of the
// user's submit button component. Remove the user's component since it
// was really just a placeholder for the real thing.

// user's submit button component.
$actions = $form['actions'];
unset($form['actions']);
unset($form['submitted'][$key]);
$form['submitted']['submit_button'] = $actions;
$form['submitted'][$key]['actions'] = $actions;
}
}
}
7 changes: 3 additions & 4 deletions webform_submit_button_component.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
function _webform_render_submit_button($component, $value = NULL, $filter = TRUE) {
$wrapper = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('placeholder-for-submit-button'),
),
'#theme_wrappers' => array('webform_element'),
'#webform_component' => $component,
'#weight' => $component['weight'],
);

return $wrapper;
}

Expand Down