/** * Get the redirect_url for this webform as used by the submit handler. * * This is mainly a c&p of the relevant parts of * @see webform_client_form_submit(). */ public function getRedirect($submission = NULL) { $node = $this->node; $redirect_url = $node->webform['redirect_url']; // Clean up the redirect URL and filter it for webform tokens. $redirect_url = trim($node->webform['redirect_url']); if ($submission) { $redirect_url = _webform_filter_values($redirect_url, $node, $submission, NULL, FALSE, TRUE); } // Remove the domain name from the redirect. $redirect_url = preg_replace('/^' . preg_quote($GLOBALS['base_url'], '/') . '\\//', '', $redirect_url); if ($redirect_url == '<none>') { return NULL; } elseif ($redirect_url == '<confirmation>') { $options = array(); if ($submission) { $options['query']['sid'] = $submission->sid; } return array('node/' . $node->nid . '/done', $options); } elseif (valid_url($redirect_url, TRUE)) { return $redirect_url; } elseif ($redirect_url && strpos($redirect_url, 'http') !== 0) { $parts = \Drupal\Component\Utility\UrlHelper::parse($redirect_url); if ($submission) { $parts['query']['sid'] = $submission->sid; } $query = $parts['query']; return array($parts['path'], array('query' => $query, 'fragment' => $parts['fragment'])); } return $redirect_url; }
/** * Render a Webform component to be part of a form. * * @param $component * A Webform component array. * @param $value * If editing an existing submission or resuming a draft, this will contain * an array of values to be shown instead of the default in the component * configuration. This value will always be an array, keyed numerically for * each value saved in this field. * @param $filter * Whether or not to filter the contents of descriptions and values when * rendering the component. Values need to be unfiltered to be editable by * Form Builder. * * @see _webform_client_form_add_component() */ function _webform_render_component($component, $value = NULL, $filter = TRUE) { $form_item = array('#type' => 'textfield', '#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'], '#required' => $component['mandatory'], '#weight' => $component['weight'], '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], '#default_value' => $filter ? _webform_filter_values($component['value']) : $component['value'], '#prefix' => '<div class="webform-component-textfield" id="webform-component-' . $component['form_key'] . '">', '#suffix' => '</div>'); if (isset($value)) { $form_item['#default_value'] = $value[0]; } return $form_item; }