本文整理汇总了PHP中Drupal\Core\Form\FormStateInterface::setValidationEnforced方法的典型用法代码示例。如果您正苦于以下问题:PHP FormStateInterface::setValidationEnforced方法的具体用法?PHP FormStateInterface::setValidationEnforced怎么用?PHP FormStateInterface::setValidationEnforced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormStateInterface
的用法示例。
在下文中一共展示了FormStateInterface::setValidationEnforced方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
// Don't show the form when batch operations are in progress.
if ($batch = batch_get() && isset($batch['current_set'])) {
return array('#theme' => '');
}
// Make sure that we validate because this form might be submitted
// multiple times per page.
$form_state->setValidationEnforced();
/** @var \Drupal\views\ViewExecutable $view */
$view = $form_state->get('view');
$display =& $form_state->get('display');
$form_state->setUserInput($view->getExposedInput());
// Let form plugins know this is for exposed widgets.
$form_state->set('exposed', TRUE);
// Check if the form was already created
if ($cache = $this->exposedFormCache->getForm($view->storage->id(), $view->current_display)) {
return $cache;
}
$form['#info'] = array();
// Go through each handler and let it generate its exposed widget.
foreach ($view->display_handler->handlers as $type => $value) {
/** @var \Drupal\views\Plugin\views\ViewsHandlerInterface $handler */
foreach ($view->{$type} as $id => $handler) {
if ($handler->canExpose() && $handler->isExposed()) {
// Grouped exposed filters have their own forms.
// Instead of render the standard exposed form, a new Select or
// Radio form field is rendered with the available groups.
// When an user choose an option the selected value is split
// into the operator and value that the item represents.
if ($handler->isAGroup()) {
$handler->groupForm($form, $form_state);
$id = $handler->options['group_info']['identifier'];
} else {
$handler->buildExposedForm($form, $form_state);
}
if ($info = $handler->exposedInfo()) {
$form['#info']["{$type}-{$id}"] = $info;
}
}
}
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#name' => '', '#type' => 'submit', '#value' => $this->t('Apply'), '#id' => drupal_html_id('edit-submit-' . $view->storage->id()));
$form['#action'] = _url($view->display_handler->getUrl());
$form['#theme'] = $view->buildThemeFunctions('views_exposed_form');
$form['#id'] = drupal_clean_css_identifier('views_exposed_form-' . String::checkPlain($view->storage->id()) . '-' . String::checkPlain($display['id']));
// $form['#attributes']['class'] = array('views-exposed-form');
/** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */
$exposed_form_plugin = $form_state->get('exposed_form_plugin');
$exposed_form_plugin->exposedFormAlter($form, $form_state);
// Save the form.
$this->exposedFormCache->setForm($view->storage->id(), $view->current_display, $form);
return $form;
}
示例2: setValidationEnforced
/**
* {@inheritdoc}
*/
public function setValidationEnforced($must_validate = TRUE)
{
$this->mainFormState->setValidationEnforced($must_validate);
return $this;
}
示例3: updateTypeDependentSet
/**
* Ajax Form call back for Create Reference Fieldset.
*
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
*
* @return
*/
public function updateTypeDependentSet(array $form, FormStateInterface $form_state) {
// $form_state->setRebuild();
$form_state->setValidationEnforced(FALSE);
return $form['type_dependent_elements'];
}
示例4: testSetValidationEnforced
/**
* @covers ::setValidationEnforced
*
* @dataProvider providerSingleBooleanArgument
*
* @param bool $must_validate
*/
public function testSetValidationEnforced($must_validate)
{
$this->decoratedFormState->setValidationEnforced($must_validate)->shouldBeCalled();
$this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setValidationEnforced($must_validate));
}