本文整理汇总了PHP中Drupal\Core\Form\FormStateInterface::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP FormStateInterface::getValues方法的具体用法?PHP FormStateInterface::getValues怎么用?PHP FormStateInterface::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormStateInterface
的用法示例。
在下文中一共展示了FormStateInterface::getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitConfigurationForm
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
{
$values = $form_state->getValues();
$values['default'] = (bool) $values['default'];
$values['roles'] = array_values(array_filter($values['roles']));
$form_state->set('values', $values);
parent::submitConfigurationForm($form, $form_state);
}
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$currency_locale = $this->configImporter->importCurrencyLocale($form_state->getValues()['locale']);
drupal_set_message($this->t('The %label has been imported.', ['%label' => $currency_locale->label()]));
if ($form_state->getTriggeringElement()['#name'] == 'import_edit') {
$form_state->setRedirectUrl($currency_locale->urlInfo('edit-form'));
} else {
$form_state->setRedirectUrl(new Url('entity.currency_locale.collection'));
}
}
示例3: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$auto_import = array();
foreach ($form_state->getValues()['auto_import'] as $file) {
$auto_import[] = array('filename' => $file, 'hash' => '');
}
$this->config(static::CONFIGNAME)->set('auto_import', $auto_import)->set('auto_export', $form_state->getValues()['auto_export'])->save();
parent::submitForm($form, $form_state);
}
示例4: blockSubmit
/**
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state)
{
$this->setConfigurationValue('flickr_source', $form_state->getValues()['flickr_source']);
$this->setConfigurationValue('flickr_userId', $form_state->getValues()['flickr_userId']);
$this->setConfigurationValue('flickr_groupId', $form_state->getValues()['flickr_groupId']);
$this->setConfigurationValue('flickr_setId', $form_state->getValues()['flickr_setId']);
$this->setConfigurationValue('flickr_num_photo', $form_state->getValues()['flickr_num_photo']);
$this->setConfigurationValue('flickr_display', $form_state->getValues()['flickr_display']);
$this->setConfigurationValue('flickr_image_size', $form_state->getValues()['flickr_image_size']);
$this->setConfigurationValue('flickr_layout', $form_state->getValues()['flickr_layout']);
$this->setConfigurationValue('flickr_tag', $form_state->getValues()['flickr_tag']);
}
示例5: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$form_values = $form_state->getValues();
$module = 'customer_contact';
$key = 'contact_message';
// Specify 'to' and 'from' addresses.
$to = "henbak@gmail.com";
$from = \Drupal::config('system.site')->get('mail');
// Output
$output = '';
$output .= 'First name: ' . $form_values['first_name'] . '\\n';
$output .= 'Last name: ' . $form_values['last_name'] . '\\n';
$output .= 'Company: ' . $form_values['company'] . '\\n';
$output .= 'Phone number: ' . $form_values['phone_number'] . '\\n';
$output .= 'Website: ' . $form_values['website'] . '\\n';
$output .= 'Know about: ' . $form_values['know_about'] . '\\n';
$output .= 'Project start: ' . $form_values['project_start'] . '\\n';
$output .= 'Price range: ' . $form_values['price_range'] . '\\n';
$output .= 'Description: ' . $form_values['description'] . '\\n';
$params = array('message' => $output);
$language_code = \Drupal::languageManager()->getDefaultLanguage()->getId();
$send_now = TRUE;
// Send the mail, and check for success. Note that this does not guarantee
// message delivery; only that there were no PHP-related issues encountered
// while sending.
$result = $this->mailManager->mail($module, $key, $to, $language_code, $params, $from, $send_now);
if ($result['result'] == TRUE) {
drupal_set_message(t('An email has been sent to Create Inside. Thank your for your time.'));
} else {
drupal_set_message(t('There was a problem sending your message.'), 'error');
}
}
示例6: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$document = array('#type' => 'texgen_document', '#texgenformdata' => $form_state->getValues());
global $_SESSION;
$_SESSION['texgen']['result'] = \Drupal::service('renderer')->render($document);
$form_state->setRedirectUrl(Url::fromRoute('texgen.page'));
}
示例7: validateExposed
/**
* {@inheritdoc}
*/
public function validateExposed(&$form, FormStateInterface $form_state)
{
// Only validate exposed input.
if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) {
return;
}
// We only need to validate if there is a minimum word length set.
if ($this->options['min_length'] < 2) {
return;
}
$identifier = $this->options['expose']['identifier'];
$input =& $form_state->getValues()[$identifier];
if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) {
$this->operator = $this->options['group_info']['group_items'][$input]['operator'];
$input =& $this->options['group_info']['group_items'][$input]['value'];
}
// If there is no input, we're fine.
if (!trim($input)) {
return;
}
$words = preg_split('/\\s+/', $input);
foreach ($words as $i => $word) {
if (Unicode::strlen($word) < $this->options['min_length']) {
unset($words[$i]);
}
}
if (!$words) {
$vars['@count'] = $this->options['min_length'];
$msg = $this->t('You must include at least one positive keyword with @count characters or more.', $vars);
$form_state->setError($form[$identifier], $msg);
}
$input = implode(' ', $words);
}
示例8: validateConfigurationForm
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
{
$values =& $form_state->getValues();
$values['allowed_schemes'] = array_filter($values['allowed_schemes']);
// Convert allowed_extensions to an array for storage.
$values['allowed_extensions'] = array_unique(explode(' ', preg_replace('/\\s+/', ' ', trim($values['allowed_extensions']))));
}
示例9: submitForm
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Display result.
foreach ($form_state->getValues() as $key => $value) {
drupal_set_message($key . ': ' . $value);
}
}
示例10: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$values = $form_state->getValues();
$entry = array('gid' => $values['gid'], 'title' => $values['title'], 'description' => $values['description'], 'time_zone' => $values['time_zone'], 'parent_gid' => empty($values['parent_gid']) ? NULL : $values['parent_gid']);
// If logo fid is changed, delete old and set new for permanent status.
$logo_fid = isset($values['logo_fid'][0]) ? $values['logo_fid'][0] : NULL;
$old_logo_fid = $values['old_logo_fid'];
if (!empty($logo_fid) && $logo_fid != $old_logo_fid) {
// Set old file for removal.
$file = file_load($old_logo_fid);
if ($file) {
\Drupal::service('file.usage')->delete($file, 'ea_groupings', 'group', $values['gid']);
}
// Add file permanently.
$file = file_load($logo_fid);
if ($file) {
$file->status = FILE_STATUS_PERMANENT;
$file->save();
\Drupal::service('file.usage')->add($file, 'ea_groupings', 'group', $values['gid']);
}
// Add new fid to entry.
$entry['logo_fid'] = $logo_fid;
}
// Save the submitted entry.
$return = EAGroupingsStorage::update($entry);
if ($return) {
drupal_set_message(t('Updated @title', array('@title' => $entry['title'])));
}
}
示例11: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// drupal_set_message($this->t('@can_name ,Your application is being submitted!', array('@can_name' => $form_state->getValue('candidate_name'))));
foreach ($form_state->getValues() as $key => $value) {
drupal_set_message($key . ': ' . $value);
}
}
示例12: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$quote_config = $this->config('uc_quote.settings');
$address = $quote_config->get('store_default_address');
$form['uc_quote_display_debug'] = array('#type' => 'checkbox', '#title' => $this->t('Display debug information to administrators.'), '#default_value' => $quote_config->get('display_debug'));
$form['uc_quote_require_quote'] = array('#type' => 'checkbox', '#title' => $this->t('Prevent the customer from completing an order if a shipping quote is not selected.'), '#default_value' => $quote_config->get('require_quote'));
$form['default_address'] = array('#type' => 'details', '#title' => $this->t('Default pickup address'), '#description' => $this->t("When delivering products to customers, the original location of the product must be known in order to accurately quote the shipping cost and set up a delivery. This form provides the default location for all products in the store. If a product's individual pickup address is blank, Ubercart uses the store's default pickup address specified here."));
$form['default_address']['address'] = array('#type' => 'uc_address', '#default_value' => $form_state->getValues() ?: $address, '#required' => FALSE);
$shipping_types = uc_quote_shipping_type_options();
if (is_array($shipping_types)) {
$form['uc_quote_type_weight'] = array('#type' => 'details', '#title' => $this->t('List position'), '#description' => $this->t('Determines which shipping methods are quoted at checkout when products of different shipping types are ordered. Larger values take precedence.'), '#tree' => TRUE);
$weight = $quote_config->get('type_weight');
$shipping_methods = \Drupal::moduleHandler()->invokeAll('uc_shipping_method');
$method_types = array();
foreach ($shipping_methods as $method) {
// Get shipping method types from shipping methods that provide quotes
if (isset($method['quote'])) {
$method_types[$method['quote']['type']][] = $method['title'];
}
}
if (isset($method_types['order']) && is_array($method_types['order'])) {
$count = count($method_types['order']);
$form['uc_quote_type_weight']['#description'] .= $this->formatPlural($count, '<br />The %list method is compatible with any shipping type.', '<br />The %list methods are compatible with any shipping type.', ['%list' => implode(', ', $method_types['order'])]);
}
foreach ($shipping_types as $id => $title) {
$form['uc_quote_type_weight'][$id] = array('#type' => 'weight', '#title' => $title . (isset($method_types[$id]) && is_array($method_types[$id]) ? ' (' . implode(', ', $method_types[$id]) . ')' : ''), '#delta' => 5, '#default_value' => isset($weight[$id]) ? $weight[$id] : 0);
}
}
$form['uc_store_shipping_type'] = array('#type' => 'select', '#title' => $this->t('Default order fulfillment type for products'), '#options' => $shipping_types, '#default_value' => $quote_config->get('shipping_type'));
return parent::buildForm($form, $form_state);
}
示例13: submitForm
/**
* Implements \Drupal\Core\Form\FormInterface::submitForm().
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$values = $form_state->getValues();
$config = $this->config('google_analytics_lite.settings');
$config->set('trackingId', $values['trackingId'])->save();
parent::submitForm($form, $form_state);
}
示例14: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$values = $form_state->getValues();
$file = File::load($values['file'][0]);
// Load File entity.
$read_file = new \SplFileObject($file->url());
// Create file handler.
$lines = 1;
$in_queue = 0;
$queue = \Drupal::queue('eventninja');
// Load queue
while (!$read_file->eof()) {
$data = $read_file->fgetcsv(';');
if ($lines > 1) {
// skip headers
$user = user_load_by_mail($data[1]);
if ($user === false) {
// Verify if user with specified email does not exist.
$queue->createItem($data);
$in_queue++;
} else {
$this->logger('eventninja')->log(RfcLogLevel::NOTICE, 'User {mail} hasn\'t been created.', ['mail' => $data[1]]);
}
}
$lines++;
}
if ($lines > 1) {
drupal_set_message($this->t('@num records was scheduled for import', array('@num' => $in_queue)), 'success');
} else {
drupal_set_message($this->t('File contains only headers'), 'error');
}
}
示例15: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Remove Form API elements from $form_state
$form_state->cleanValues();
db_merge('uc_attributes')->key(array('aid' => $form_state->getValue('aid')))->fields($form_state->getValues())->execute();
$form_state->setRedirect('uc_attribute.overview');
}