本文整理汇总了PHP中Drupal\Core\Form\FormStateInterface::loadInclude方法的典型用法代码示例。如果您正苦于以下问题:PHP FormStateInterface::loadInclude方法的具体用法?PHP FormStateInterface::loadInclude怎么用?PHP FormStateInterface::loadInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormStateInterface
的用法示例。
在下文中一共展示了FormStateInterface::loadInclude方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: settingsForm
/**
* {@inheritdoc}
*
* @see \Drupal\editor\Form\EditorImageDialog
* @see editor_image_upload_settings_form()
*/
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor)
{
$form_state->loadInclude('editor', 'admin.inc');
$form['image_upload'] = editor_image_upload_settings_form($editor);
$form['image_upload']['#attached']['library'][] = 'ckeditor/drupal.ckeditor.drupalimage.admin';
$form['image_upload']['#element_validate'][] = array($this, 'validateImageUploadSettings');
return $form;
}
示例2: loadInclude
/**
* {@inheritdoc}
*/
public function loadInclude($module, $type, $name = NULL)
{
return $this->mainFormState->loadInclude($module, $type, $name);
}
示例3: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$account = \Drupal::currentUser();
$form = ['#attached' => ['library' => ['webform/webform']]];
$form_state->loadInclude('webform', 'inc', 'includes/webform.components');
$form_state->loadInclude('webform', 'inc', 'includes/webform.submissions');
// For ajax requests, $form_state->getValue('details') is missing. Restore
// from storage, if available, for multi-page forms.
if (empty($form_state->getValue('details')) && !empty($form_state->getValue(['storage', 'details']))) {
$form_state->setValue('details', $form_state->getValue(['storage', 'details']));
}
$node = $this->node;
$submission = $this->node;
$resume_draft = $this->resume_draft;
$filter = $this->filter;
// If in a multi-step form, a submission ID may be specified in form state.
// Load this submission. This allows anonymous users to use auto-save.
if (empty($submission) && !empty($form_state->getValue(['details', 'sid']))) {
$submission = webform_get_submission($node->id(), $form_state->getValue(['details', 'sid']));
}
$finished = isset($submission->is_draft) ? !$submission->is_draft : 0;
$submit_button_text = $finished ? $this->t('Save') : (empty($node->webform['submit_text']) ? $this->t('Submit') : $node->webform['submit_text']);
// Bind arguments to $form to make them available in theming and form_alter.
$form['#node'] = $node;
$form['#submission'] = $submission;
$form['#filter'] = $filter;
// Add a theme function for this form.
$form['#theme'] = ['webform_form_' . $node->id(), 'webform_form'];
// Add a CSS class for all client forms.
$form['#attributes']['class'][] = 'webform-client-form';
$form['#attributes']['class'][] = 'webform-client-form-' . $node->id();
// Set the encoding type (necessary for file uploads).
$form['#attributes']['enctype'] = 'multipart/form-data';
// Sometimes when displaying a webform as a teaser or block, a custom action
// property is set to direct the user to the node page.
if (!empty($node->webform['action'])) {
$form['#action'] = $node->webform['action'];
}
// @todo Convert these to methods.
$form['#submit'] = ['webform_client_form_pages', 'webform_client_form_submit'];
$form['#validate'] = ['webform_client_form_validate'];
// Add includes for used component types and pre/post validation handlers
$form['#process'] = ['webform_client_form_process'];
if (is_array($node->webform['components']) && !empty($node->webform['components'])) {
// Prepare a new form array.
$form['submitted'] = ['#tree' => TRUE];
$form['details'] = ['#tree' => TRUE];
// Put the components into a tree structure.
if (!isset($form_state->getStorage()['component_tree'])) {
$form_state->set(['webform', 'component_tree'], []);
$form_state->set(['webform', 'page_count'], 1);
$form_state->set(['webform', 'page_num'], 1);
_webform_components_tree_build($node->webform['components'], $form_state->get(['webform', 'component_tree']), 0, $form_state->get(['webform', 'page_count']));
// If preview is enabled, increase the page count by one.
if ($node->webform['preview']) {
$form_state->set(['webform', 'page_count'], $form_state->get(['webform', 'page_count']) + 1);
}
$form_state->set(['webform', 'preview'], $node->webform['preview']);
// If this is the first time this draft has been restore and presented
// to the user, let them know that they are looking at a draft, rather
// than a new form. This applies to the node view page, but not to a
// submission edit page (where they presumably know what submission they
// are editing).
if ($resume_draft && empty($form_state->getUserInput())) {
drupal_set_message($this->t('A partially-completed form was found. Please complete the remaining portions.'));
}
} else {
$form_state->set(['webform', 'component_tree'], $form_state->getStorage()['component_tree']);
$form_state->set(['webform', 'page_count'], $form_state->getStorage()['page_count']);
$form_state->set(['webform', 'page_num'], $form_state->getStorage()['page_num']);
$form_state->set(['webform', 'preview'], $form_state->getStorage()['preview']);
}
// Set the input values based on whether we're editing an existing
// submission or not.
$input_values = isset($submission->data) ? $submission->data : [];
// Form state storage override any default submission information. Convert
// the value structure to always be an array, matching $submission->data.
if (isset($form_state->getStorage()['submitted'])) {
foreach ($form_state->getStorage()['submitted'] as $cid => $data) {
$input_values[$cid] = is_array($data) ? $data : [$data];
}
}
// Form state values override any default submission information. Convert
// the value structure to always be an array, matching $submission->data.
if ($form_state->getValue('submitted')) {
foreach ($form_state->getValue('submitted') as $cid => $data) {
$input_values[$cid] = is_array($data) ? $data : [$data];
}
}
// Generate conditional topological order & report any errors.
$sorter = webform_get_conditional_sorter($node);
$sorter->reportErrors();
// Execute the conditionals on the current input values
$input_values = $sorter->executeConditionals($input_values);
// Allow values from other pages to be sent to browser for conditionals.
$form['#conditional_values'] = $input_values;
// Allow components access to most up-to-date values.
//.........这里部分代码省略.........
示例4: testLoadInclude
/**
* @covers ::loadInclude
*
* @dataProvider providerLoadInclude
*
* @param string|false $expected
* @param string $module
* @param string $type
* @param string|null $name
*/
public function testLoadInclude($expected, $module, $type, $name)
{
$this->decoratedFormState->loadInclude($module, $type, $name)->willReturn($expected)->shouldBeCalled();
$this->assertSame($expected, $this->formStateDecoratorBase->loadInclude($module, $type, $name));
}