当前位置: 首页>>代码示例>>PHP>>正文


PHP FormStateInterface::setUserInput方法代码示例

本文整理汇总了PHP中Drupal\Core\Form\FormStateInterface::setUserInput方法的典型用法代码示例。如果您正苦于以下问题:PHP FormStateInterface::setUserInput方法的具体用法?PHP FormStateInterface::setUserInput怎么用?PHP FormStateInterface::setUserInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Form\FormStateInterface的用法示例。


在下文中一共展示了FormStateInterface::setUserInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     if ($form_state->isRebuilding()) {
         $form_state->setUserInput(array());
     }
     // Initialize
     $storage = $form_state->getStorage();
     if (empty($storage)) {
         $user_input = $form_state->getUserInput();
         if (empty($user_input)) {
             $_SESSION['constructions'] = 0;
         }
         // Put the initial thing into the storage
         $storage = ['thing' => ['title' => 'none', 'value' => '']];
         $form_state->setStorage($storage);
     }
     // Count how often the form is constructed.
     $_SESSION['constructions']++;
     drupal_set_message("Form constructions: " . $_SESSION['constructions']);
     $form['title'] = array('#type' => 'textfield', '#title' => 'Title', '#default_value' => $storage['thing']['title'], '#required' => TRUE);
     $form['value'] = array('#type' => 'textfield', '#title' => 'Value', '#default_value' => $storage['thing']['value'], '#element_validate' => array('::elementValidateValueCached'));
     $form['continue_button'] = array('#type' => 'button', '#value' => 'Reset');
     $form['continue_submit'] = array('#type' => 'submit', '#value' => 'Continue submit', '#submit' => array('::continueSubmitForm'));
     $form['submit'] = array('#type' => 'submit', '#value' => 'Save');
     if (\Drupal::request()->get('cache')) {
         // Manually activate caching, so we can test that the storage keeps working
         // when it's enabled.
         $form_state->setCached();
     }
     if ($this->getRequest()->get('immutable')) {
         $form_state->addBuildInfo('immutable', TRUE);
     }
     return $form;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:37,代码来源:FormTestStorageForm.php

示例2: 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;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:58,代码来源:ViewsExposedForm.php

示例3: valueForm

 protected function valueForm(&$form, FormStateInterface $form_state)
 {
     $users = $this->value ? User::loadMultiple($this->value) : array();
     $default_value = EntityAutocomplete::getEntityLabels($users);
     $form['value'] = array('#type' => 'entity_autocomplete', '#title' => $this->t('Usernames'), '#description' => $this->t('Enter a comma separated list of user names.'), '#target_type' => 'user', '#tags' => TRUE, '#default_value' => $default_value, '#process_default_value' => FALSE);
     $user_input = $form_state->getUserInput();
     if ($form_state->get('exposed') && !isset($user_input[$this->options['expose']['identifier']])) {
         $user_input[$this->options['expose']['identifier']] = $default_value;
         $form_state->setUserInput($user_input);
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:11,代码来源:Name.php

示例4: valueForm

 /**
  * Provide a simple textfield for equality
  */
 protected function valueForm(&$form, FormStateInterface $form_state)
 {
     $form['value'] = array('#type' => 'textfield', '#title' => $this->t('Value'), '#size' => 30, '#default_value' => $this->value);
     if ($exposed = $form_state->get('exposed')) {
         $identifier = $this->options['expose']['identifier'];
         $user_input = $form_state->getUserInput();
         if (!isset($user_input[$identifier])) {
             $user_input[$identifier] = $this->value;
             $form_state->setUserInput($user_input);
         }
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:Equality.php

示例5: view

 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $contents['#attached']['library'][] = 'uc_payment/uc_payment.styles';
     if ($this->configuration['show_preview']) {
         $contents['line_items'] = array('#theme' => 'uc_payment_totals', '#order' => $order, '#weight' => -20);
     }
     // Ensure that the form builder uses #default_value to determine which
     // button should be selected after an ajax submission. This is
     // necessary because the previously selected value may have become
     // unavailable, which would result in an invalid selection.
     $input = $form_state->getUserInput();
     unset($input['panes']['payment']['payment_method']);
     $form_state->setUserInput($input);
     $options = array();
     $methods = PaymentMethod::loadMultiple();
     uasort($methods, 'Drupal\\uc_payment\\Entity\\PaymentMethod::sort');
     foreach ($methods as $method) {
         // $set = rules_config_load('uc_payment_method_' . $method['id']);
         // if ($set && !$set->execute($order)) {
         //   continue;
         // }
         if ($method->status()) {
             $options[$method->id()] = $method->getDisplayLabel();
         }
     }
     \Drupal::moduleHandler()->alter('uc_payment_method_checkout', $options, $order);
     if (!$options) {
         $contents['#description'] = $this->t('Checkout cannot be completed without any payment methods enabled. Please contact an administrator to resolve the issue.');
         $options[''] = $this->t('No payment methods available');
     } elseif (count($options) > 1) {
         $contents['#description'] = $this->t('Select a payment method from the following options.');
     }
     if (!$order->getPaymentMethodId() || !isset($options[$order->getPaymentMethodId()])) {
         $order->setPaymentMethodId(key($options));
     }
     $contents['payment_method'] = array('#type' => 'radios', '#title' => $this->t('Payment method'), '#title_display' => 'invisible', '#options' => $options, '#default_value' => $order->getPaymentMethodId(), '#disabled' => count($options) == 1, '#required' => TRUE, '#ajax' => array('callback' => array($this, 'ajaxRender'), 'wrapper' => 'payment-details', 'progress' => array('type' => 'throbber')));
     // If there are no payment methods available, this will be ''.
     if ($order->getPaymentMethodId()) {
         $plugin = $this->paymentMethodManager->createFromOrder($order);
         $definition = $plugin->getPluginDefinition();
         $contents['details'] = array('#prefix' => '<div id="payment-details" class="clearfix ' . Html::cleanCssIdentifier('payment-details-' . $definition['id']) . '">', '#markup' => $this->t('Continue with checkout to complete payment.'), '#suffix' => '</div>');
         try {
             $details = $plugin->cartDetails($order, $form, $form_state);
             if ($details) {
                 unset($contents['details']['#markup']);
                 $contents['details'] += $details;
             }
         } catch (PluginException $e) {
         }
     }
     return $contents;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:55,代码来源:PaymentMethodPane.php

示例6: loadBundleValues

 /**
  * Load the values from the bundle into the user input.
  * Used during Ajax callback since updating #default_values is ignored.
  * @param $bundle_name
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  */
 protected function loadBundleValues(FormStateInterface &$form_state, $current_bundle, $enabled_methods, $methods_weight)
 {
     $input = $form_state->getUserInput();
     $input['bundle']['name'] = $current_bundle->isDefault() ? '' : $current_bundle->getName();
     $input['bundle']['machine_name'] = $current_bundle->getMachineName();
     $input['bundle']['description'] = $current_bundle->isDefault() ? '' : $current_bundle->getDescription();
     $input['bundle']['is_profile'] = $current_bundle->isProfile() ? 1 : null;
     $input['bundle']['profile_name'] = $current_bundle->isProfile() ? $current_bundle->getProfileName() : '';
     foreach ($methods_weight as $method_id => $weight) {
         $enabled = isset($enabled_methods[$method_id]);
         $input['weight'][$method_id] = $weight;
         $input['enabled'][$method_id] = $enabled ? 1 : null;
     }
     $form_state->setUserInput($input);
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:21,代码来源:AssignmentConfigureForm.php

示例7: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     if ($form_state->hasValue('date')) {
         $userInput = $form_state->getUserInput();
         $userInput['result'] = 'Date Set';
         $form_state->setUserInput($userInput);
     } else {
         $form_state->setValue('date', date('Y-m-d', REQUEST_TIME));
         $form_state->setValue('result', 'date not set');
         $result = 'Date Not Set';
     }
     $form['ajax_wrapper'] = ['#type' => 'container', '#attributes' => ['id' => 'ajax_wrapper']];
     $form['ajax_wrapper']['date'] = ['#type' => 'date', '#title' => $this->t('Date')];
     $form['ajax_wrapper']['submit_button'] = ['#type' => 'submit', '#value' => 'Load', '#ajax' => ['callback' => [$this, 'ajaxFormCallback']]];
     $form['ajax_wrapper']['result'] = ['#type' => 'textfield', '#title' => $this->t('Result'), '#default_value' => $result];
     return $form;
 }
开发者ID:mgrimard,项目名称:drupal8_ajax_form,代码行数:20,代码来源:AjaxForm.php

示例8: view

 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $user = \Drupal::currentUser();
     $pane = $this->pluginDefinition['id'];
     $source = $this->sourcePaneId();
     $contents['#description'] = $this->getDescription();
     if ($source != $pane) {
         $contents['copy_address'] = array('#type' => 'checkbox', '#title' => $this->getCopyAddressText(), '#default_value' => $this->configuration['default_same_address'], '#ajax' => array('callback' => array($this, 'ajaxRender'), 'wrapper' => $pane . '-address-pane', 'progress' => array('type' => 'throbber')));
     }
     if ($user->isAuthenticated() && ($addresses = uc_select_addresses($user->id(), $pane))) {
         $contents['select_address'] = array('#type' => 'select', '#title' => t('Saved addresses'), '#options' => $addresses['#options'], '#ajax' => array('callback' => array($this, 'ajaxRender'), 'wrapper' => $pane . '-address-pane', 'progress' => array('type' => 'throbber')), '#states' => array('invisible' => array('input[name="panes[' . $pane . '][copy_address]"]' => array('checked' => TRUE))));
     }
     $contents['address'] = array('#type' => 'uc_address', '#default_value' => $order->getAddress($pane), '#prefix' => '<div id="' . $pane . '-address-pane">', '#suffix' => '</div>');
     if ($form_state->hasValue(['panes', $pane, 'copy_address'])) {
         $contents['address']['#hidden'] = !$form_state->isValueEmpty(['panes', $pane, 'copy_address']);
     } elseif (isset($contents['copy_address'])) {
         $contents['address']['#hidden'] = $this->configuration['default_same_address'];
     }
     if ($element = $form_state->getTriggeringElement()) {
         $input = $form_state->getUserInput();
         if ($element['#name'] == "panes[{$pane}][copy_address]") {
             $address =& $form_state->getValue(['panes', $source]);
             foreach ($address as $field => $value) {
                 if (substr($field, 0, strlen($source)) == $source) {
                     $field = str_replace($source, $pane, $field);
                     $input['panes'][$pane][$field] = $value;
                     $order->{$field} = $value;
                 }
             }
         }
         if ($element['#name'] == "panes[{$pane}][select_address]") {
             $address = $addresses[$element['#value']];
             foreach ($address as $field => $value) {
                 $input['panes'][$pane][$pane . '_' . $field] = $value;
                 $order->{$pane . '_' . $field} = $value;
             }
         }
         $form_state->setUserInput($input);
         // Forget any previous Ajax submissions, as we send new default values.
         $form_state->unsetValue('uc_address');
     }
     return $contents;
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:46,代码来源:AddressPaneBase.php

示例9: fieldSubmitForm

 /**
  * Form element submit handler for mollom_test_form().
  */
 function fieldSubmitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove all empty values of the multiple value field.
     $form_state->setValue('field', array_filter($form_state->getValue('field')));
     // Update the storage with submitted values.
     $storage_record = $form_state->getValues();
     // Store the new value and clear out the 'new' field.
     $new_field = $form_state->getValue(array('field', 'new'), '');
     if (!empty($new_field)) {
         $storage_record['field'][] = $form_state->getValue(array('field', 'new'));
         $form_state->setValue(array('field', 'new'), '');
         $storage_record['field']['new'] = '';
         unset($storage_record['field']['add']);
         $input = $form_state->getUserInput();
         $input['field']['new'] = '';
         $form_state->setUserInput($input);
     }
     $form_state->set('mollom_test', $storage_record);
     $form_state->setRebuild(TRUE);
 }
开发者ID:ABaldwinHunter,项目名称:durhamatletico-cms,代码行数:23,代码来源:PostForm.php

示例10: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     if ($form_state->isRebuilding()) {
         $form_state->setUserInput(array());
     }
     // Initialize
     $storage = $form_state->getStorage();
     if (empty($storage)) {
         $user_input = $form_state->getUserInput();
         if (empty($user_input)) {
             $_SESSION['constructions'] = 0;
         }
         // Put the initial thing into the storage
         $storage = ['thing' => ['title' => 'none', 'value' => '']];
         $form_state->setStorage($storage);
     }
     // Count how often the form is constructed.
     $_SESSION['constructions']++;
     drupal_set_message("Form constructions: " . $_SESSION['constructions']);
     $form['title'] = array('#type' => 'textfield', '#title' => 'Title', '#default_value' => $storage['thing']['title'], '#required' => TRUE);
     $form['value'] = array('#type' => 'textfield', '#title' => 'Value', '#default_value' => $storage['thing']['value'], '#element_validate' => array('::elementValidateValueCached'));
     $form['continue_button'] = array('#type' => 'button', '#value' => 'Reset');
     $form['continue_submit'] = array('#type' => 'submit', '#value' => 'Continue submit', '#submit' => array('::continueSubmitForm'));
     $form['submit'] = array('#type' => 'submit', '#value' => 'Save');
     // @todo Remove this in https://www.drupal.org/node/2524408, because form
     //   cache immutability is no longer necessary, because we no longer cache
     //   forms during safe HTTP methods. In the meantime, because
     //   Drupal\system\Tests\Form still has test coverage for a poisoned form
     //   cache following a GET request, trick $form_state into caching the form
     //   to keep that test working until we either remove it or change it in
     //   that issue.
     if ($this->getRequest()->get('immutable')) {
         $form_state->addBuildInfo('immutable', TRUE);
         if ($this->getRequest()->get('cache') && $this->getRequest()->isMethodSafe()) {
             $form_state->setRequestMethod('FAKE');
             $form_state->setCached();
         }
     }
     return $form;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:43,代码来源:FormTestStorageForm.php

示例11: prepare

 /**
  * {@inheritdoc}
  */
 public function prepare(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     // If a quote was explicitly selected, add it to the order.
     if (isset($form['panes']['quotes']['quotes']['quote_option']['#value']) && isset($form['panes']['quotes']['quotes']['quote_option']['#default_value']) && $form['panes']['quotes']['quotes']['quote_option']['#value'] !== $form['panes']['quotes']['quotes']['quote_option']['#default_value']) {
         $quote_option = explode('---', $form_state->getValue(['panes', 'quotes', 'quotes', 'quote_option']));
         $order->quote['method'] = $quote_option[0];
         $order->quote['accessorials'] = $quote_option[1];
         $order->data->uc_quote_selected = TRUE;
     }
     // If the current quote was never explicitly selected, discard it and
     // use the default.
     if (empty($order->data->uc_quote_selected)) {
         unset($order->quote);
     }
     // Ensure that the form builder uses the default value to decide which
     // radio button should be selected.
     $input = $form_state->getUserInput();
     unset($input['panes']['quotes']['quotes']['quote_option']);
     $form_state->setUserInput($input);
     $order->quote_form = uc_quote_build_quote_form($order, !$form_state->get('quote_requested'));
     $default_option = _uc_quote_extract_default_option($order->quote_form);
     if ($default_option) {
         $order->quote['rate'] = $order->quote_form[$default_option]['rate']['#value'];
         $quote_option = explode('---', $default_option);
         $order->quote['method'] = $quote_option[0];
         $order->quote['accessorials'] = $quote_option[1];
         $methods = uc_quote_methods();
         $method = $methods[$quote_option[0]];
         $label = $method['quote']['accessorials'][$quote_option[1]];
         $result = db_query("SELECT line_item_id FROM {uc_order_line_items} WHERE order_id = :id AND type = :type", [':id' => $order->id(), ':type' => 'shipping']);
         if ($lid = $result->fetchField()) {
             uc_order_update_line_item($lid, $label, $order->quote['rate']);
         } else {
             uc_order_line_item_add($order->id(), 'shipping', $label, $order->quote['rate']);
         }
     } else {
         unset($order->quote);
     }
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:42,代码来源:QuotePane.php

示例12: valueForm

 protected function valueForm(&$form, FormStateInterface $form_state)
 {
     $values = array();
     if ($this->value) {
         $result = entity_load_multiple_by_properties('user', array('uid' => $this->value));
         foreach ($result as $account) {
             if ($account->id()) {
                 $values[] = $account->getUsername();
             } else {
                 $values[] = 'Anonymous';
                 // Intentionally NOT translated.
             }
         }
     }
     sort($values);
     $default_value = implode(', ', $values);
     $form['value'] = array('#type' => 'textfield', '#title' => $this->t('Usernames'), '#description' => $this->t('Enter a comma separated list of user names.'), '#default_value' => $default_value, '#autocomplete_route_name' => 'user.autocomplete_anonymous');
     $user_input = $form_state->getUserInput();
     if ($form_state->get('exposed') && !isset($user_input[$this->options['expose']['identifier']])) {
         $user_input[$this->options['expose']['identifier']] = $default_value;
         $form_state->setUserInput($user_input);
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:23,代码来源:Name.php

示例13: groupForm

 /**
  * Build a form containing a group of operator | values to apply as a
  * single filter.
  */
 public function groupForm(&$form, FormStateInterface $form_state)
 {
     if (!empty($this->options['group_info']['optional']) && !$this->multipleExposedInput()) {
         $groups = array('All' => $this->t('- Any -'));
     }
     foreach ($this->options['group_info']['group_items'] as $id => $group) {
         if (!empty($group['title'])) {
             $groups[$id] = $id != 'All' ? $this->t($group['title']) : $group['title'];
         }
     }
     if (count($groups)) {
         $value = $this->options['group_info']['identifier'];
         $form[$value] = array('#title' => $this->options['group_info']['label'], '#type' => $this->options['group_info']['widget'], '#default_value' => $this->group_info, '#options' => $groups);
         if (!empty($this->options['group_info']['multiple'])) {
             if (count($groups) < 5) {
                 $form[$value]['#type'] = 'checkboxes';
             } else {
                 $form[$value]['#type'] = 'select';
                 $form[$value]['#size'] = 5;
                 $form[$value]['#multiple'] = TRUE;
             }
             unset($form[$value]['#default_value']);
             $user_input = $form_state->getUserInput();
             if (empty($user_input)) {
                 $user_input[$value] = $this->group_info;
                 $form_state->setUserInput($user_input);
             }
         }
         $this->options['expose']['label'] = '';
     }
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:35,代码来源:FilterPluginBase.php

示例14: exposedFormAlter

 /**
  * Alters the view exposed form.
  *
  * @param $form
  *   The form build array. Passed by reference.
  * @param $form_state
  *   The form state. Passed by reference.
  */
 public function exposedFormAlter(&$form, FormStateInterface $form_state)
 {
     if (!empty($this->options['submit_button'])) {
         $form['actions']['submit']['#value'] = $this->options['submit_button'];
     }
     // Check if there is exposed sorts for this view
     $exposed_sorts = array();
     foreach ($this->view->sort as $id => $handler) {
         if ($handler->canExpose() && $handler->isExposed()) {
             $exposed_sorts[$id] = Html::escape($handler->options['expose']['label']);
         }
     }
     if (count($exposed_sorts)) {
         $form['sort_by'] = array('#type' => 'select', '#options' => $exposed_sorts, '#title' => $this->options['exposed_sorts_label']);
         $sort_order = array('ASC' => $this->options['sort_asc_label'], 'DESC' => $this->options['sort_desc_label']);
         $user_input = $form_state->getUserInput();
         if (isset($user_input['sort_by']) && isset($this->view->sort[$user_input['sort_by']])) {
             $default_sort_order = $this->view->sort[$user_input['sort_by']]->options['order'];
         } else {
             $first_sort = reset($this->view->sort);
             $default_sort_order = $first_sort->options['order'];
         }
         if (!isset($user_input['sort_by'])) {
             $keys = array_keys($exposed_sorts);
             $user_input['sort_by'] = array_shift($keys);
             $form_state->setUserInput($user_input);
         }
         if ($this->options['expose_sort_order']) {
             $form['sort_order'] = array('#type' => 'select', '#options' => $sort_order, '#title' => $this->t('Order', array(), array('context' => 'Sort order')), '#default_value' => $default_sort_order);
         }
         $form['submit']['#weight'] = 10;
     }
     if (!empty($this->options['reset_button'])) {
         $form['actions']['reset'] = array('#value' => $this->options['reset_button_label'], '#type' => 'submit', '#weight' => 10);
         // Get an array of exposed filters, keyed by identifier option.
         $exposed_filters = [];
         foreach ($this->view->filter as $id => $handler) {
             if ($handler->canExpose() && $handler->isExposed() && !empty($handler->options['expose']['identifier'])) {
                 $exposed_filters[$handler->options['expose']['identifier']] = $id;
             }
         }
         $all_exposed = array_merge($exposed_sorts, $exposed_filters);
         // Set the access to FALSE if there is no exposed input.
         if (!array_intersect_key($all_exposed, $this->view->getExposedInput())) {
             $form['actions']['reset']['#access'] = FALSE;
         }
     }
     $pager = $this->view->display_handler->getPlugin('pager');
     if ($pager) {
         $pager->exposedFormAlter($form, $form_state);
         $form_state->set('pager_plugin', $pager);
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:61,代码来源:ExposedFormPluginBase.php

示例15: simulateFormSubmission

 /**
  * Simulates a form submission within a request, bypassing submitForm().
  *
  * Calling submitForm() will reset the form builder, if two forms were on the
  * same page, they will be submitted simultaneously.
  *
  * @param string $form_id
  *   The unique string identifying the form.
  * @param \Drupal\Core\Form\FormInterface $form_arg
  *   The form object.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  * @param bool $programmed
  *   Whether $form_state->setProgrammed() should be passed TRUE or not. If it
  *   is not set to TRUE, you must provide additional data in $form_state for
  *   the submission to take place.
  *
  * @return array
  *   The built form.
  */
 protected function simulateFormSubmission($form_id, FormInterface $form_arg, FormStateInterface $form_state, $programmed = TRUE)
 {
     $input = $form_state->getUserInput();
     $input['op'] = 'Submit';
     $form_state->setUserInput($input)->setProgrammed($programmed)->setSubmitted();
     return $this->formBuilder->buildForm($form_arg, $form_state);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:27,代码来源:FormTestBase.php


注:本文中的Drupal\Core\Form\FormStateInterface::setUserInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。