Commit ebf5e34c authored by acrollet's avatar acrollet

Handle webforms with pages

parent 30346ddb
......@@ -12,7 +12,7 @@ use Drupal\node\Entity\Node;
function bee_webform_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (isset($form['#webform_id'])) {
$webform = \Drupal\webform\Entity\Webform::load($form['#webform_id']);
foreach ($webform->getElementsDecodedAndFlattened() as $element) {
foreach ($webform->getElementsDecodedAndFlattened() as $element_id => $element) {
if ($element['#type'] == 'webform_bee_reservation_form') {
$form['actions']['submit']['#submit'][] = 'bee_webform_form_submit';
}
......@@ -20,11 +20,18 @@ function bee_webform_form_alter(&$form, FormStateInterface $form_state, $form_id
}
}
/**
* bee_webform submission handler.
*/
function bee_webform_form_submit($form, FormStateInterface $form_state) {
foreach ($form['elements'] as $id => $element) {
if ($element['#type'] == 'webform_bee_reservation_form') {
$value = $form_state->getValue($id);
$webform = \Drupal\webform\Entity\Webform::load($form['#webform_id']);
foreach ($webform->getElementsDecodedAndFlattened() as $element_id => $element) {
if ($element['#type'] == 'webform_bee_reservation_form') {
$bee_element_id = $element_id;
}
}
$value = $form_state->getValue($bee_element_id);
if ($value['content_type'] && $value['start_date'] && $value['end_date'] && $value['capacity']) {
$webform_submission = $form_state->getFormObject()->getEntity();
......@@ -153,8 +160,6 @@ function bee_webform_form_submit($form, FormStateInterface $form_state) {
drupal_set_message($message);
\Drupal::logger('bee_webform')->notice($message);
}
}
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment