本文整理汇总了PHP中Drupal\Core\Form\FormStateInterface::cleanValues方法的典型用法代码示例。如果您正苦于以下问题:PHP FormStateInterface::cleanValues方法的具体用法?PHP FormStateInterface::cleanValues怎么用?PHP FormStateInterface::cleanValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormStateInterface
的用法示例。
在下文中一共展示了FormStateInterface::cleanValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$form_state->cleanValues();
// This won't have a proper JSON header, but Drupal doesn't check for that
// anyway so this is fine until it's replaced with a JsonResponse.
print Json::encode($form_state->getValues());
exit;
}
示例3: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Remove Form API elements from $form_state
$form_state->cleanValues();
db_merge('uc_attribute_options')->key(array('aid' => $form_state->getValue('aid'), 'oid' => $form_state->getValue('oid')))->fields($form_state->getValues())->execute();
drupal_set_message($this->t('Updated option %option.', ['%option' => $form_state->getValue('name')]));
$this->logger('uc_attribute')->notice('Updated option %option.', ['%option' => $form_state->getValue('name'), 'link' => 'admin/store/products/attributes/' . $form_state->getValue('aid') . '/options/' . $form_state->getValue('oid')]);
$form_state->setRedirect('uc_attribute.options', ['aid' => $form_state->getValue('aid')]);
}
示例4: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$builder = $this->createBuilder($form_state->getValue('builder_id'));
$values = $form_state->cleanValues()->getValues();
$view = $builder->createView($values);
$view->save();
// Redirect the user to the view admin form.
$form_state->setRedirectUrl($view->toUrl('edit-form'));
}
示例5: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$config = $this->config('better_formats.settings');
$form_state->cleanValues();
foreach ($form_state->getValues() as $key => $value) {
$config->set($key, $value);
}
$config->save();
parent::submitForm($form, $form_state);
}
示例6: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Remove Form API elements from $form_state
$form_state->cleanValues();
$aid = db_insert('uc_attributes')->fields($form_state->getValues())->execute();
if ($form_state->getValue('display') == 0) {
// No options needed/allowed for Textfield display type.
$form_state->setRedirect('uc_attribute.overview', ['aid' => $aid]);
} else {
// All other display types we redirect to add options.
$form_state->setRedirect('uc_attribute.options', ['aid' => $aid]);
}
}
示例7: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$node = $form['#node'];
/** @var \Drupal\webform\ComponentBase $component */
$component = $form['#component'];
$values = $form_state->cleanValues()->getValues();
$component->setConfiguration($values);
$component->save();
drupal_set_message($this->t('Changes to the webform have been saved.'));
$config = $component->getConfiguration();
// @todo Is value actually being used in the form after save()?
$form['cid'] = array('#type' => 'value', '#value' => $config['cid']);
$form_state->setRedirect('webform.components', array('node' => $node->id()));
}
示例8: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$admin = $form_state->getValue('administer_users');
if (!\Drupal::config('user.settings')->get('verify_mail') || $admin) {
$pass = $form_state->getValue('pass');
} else {
$pass = user_password();
}
// Remove unneeded values.
$form_state->cleanValues();
$form_state->setValue('pass', $pass);
$form_state->setValue('init', $form_state->getValue('mail'));
parent::submitForm($form, $form_state);
}
示例9: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->cleanValues()->getValues();
$config = $this->configFactory()->getEditable('eform.type_defaults');
$keys = array_keys($config->getRawData());
foreach ($keys as $key) {
$config->clear($key);
}
foreach ($values as $key => $value) {
$config->set($key, $value);
}
$config->save();
parent::submitForm($form, $form_state);
}
示例10: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$form_state->cleanValues();
if ($form_state->hasValue('mid')) {
db_merge('uc_weightquote_methods')->key(array('mid' => $form_state->getValue('mid')))->fields($form_state->getValues())->execute();
drupal_set_message(t('Weight quote shipping method was updated.'));
$form_state->setRedirect('uc_quote.methods');
} else {
db_insert('uc_weightquote_methods')->fields($form_state->getValues())->execute();
// Ensure Rules picks up the new condition.
// entity_flush_caches();
drupal_set_message(t('Created and enabled new weight quote shipping method.'));
$form_state->setRedirect('uc_quote.methods');
//$form_state['redirect'] = 'admin/store/config/quotes/manage/get_quote_from_weightquote_' . $form_state->getValue('mid');
}
}
示例11: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state->cleanValues();
$plugin_data = (new FormState())->setValues($form_state->getValues());
$this->linkitMatcher->submitConfigurationForm($form, $plugin_data);
$this->linkitProfile->save();
drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->linkitMatcher->getLabel())));
$this->logger('linkit')->notice('The matcher %label has been updated in the @profile profile.', [
'%label' => $this->linkitMatcher->getLabel(),
'@profile' => $this->linkitProfile->label(),
]);
$form_state->setRedirect('linkit.matchers', [
'linkit_profile' => $this->linkitProfile->id(),
]);
}
示例12: submitForm
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state->cleanValues();
/** @var \Drupal\fillpdf\FillPdfFormInterface $fillpdf_form */
$fillpdf_form = $this->getEntity();
$mappings = $form_state->getValue('mappings');
/** @var \Drupal\fillpdf\FillPdfFormInterface $imported_form */
$imported_form = $mappings['form'];
/** @var array $imported_fields */
$imported_fields = $mappings['fields'];
$unmatched_pdf_keys = $this->serializer->importForm($fillpdf_form, $imported_form, $imported_fields);
foreach ($unmatched_pdf_keys as $unmatched_pdf_key) {
drupal_set_message($this->t('Your code contained field mappings for the PDF field key <em>@pdf_key</em>, but it does not exist on this form. Therefore, it was ignored.', ['@pdf_key' => $unmatched_pdf_key]), 'warning');
}
drupal_set_message($this->t('Successfully imported FillPDF form configuration and matching PDF field keys. If any field mappings failed to import, they are listed above.'));
$form_state->setRedirect('entity.fillpdf_form.edit_form', ['fillpdf_form' => $fillpdf_form->id()]);
}
示例13: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$form_state->cleanValues();
$layout_blocks = $form_state->getValue('layout', []);
if (!is_array($layout_blocks)) {
$layout_blocks = [];
}
// If no content blocks has been created for this entity then we need to
// transfer the default blocks to the loaded content entity as entity
// layout blocks.
if (!$this->entityLayoutService->hasContentBlocks($this->entity, $this->contentEntity)) {
$block_collection = $this->entity->getDefaultBlocks();
// Update the default blocks with new configuration values from the
// form state before transferring the blocks since weights may have
// been changed.
foreach ($layout_blocks as $layout_block_id => $layout_block_configuration) {
$configuration = $block_collection->get($layout_block_id)->getConfiguration();
$block_collection->setInstanceConfiguration($layout_block_id, $layout_block_configuration + $configuration);
}
$this->entityLayoutService->transferBlocks($this->entity, $this->contentEntity, $block_collection);
} else {
$content_blocks = $this->entityLayoutService->getContentBlocksByEntity($this->contentEntity);
foreach ($layout_blocks as $layout_block_id => $layout_block_configuration) {
foreach ($content_blocks as $content_block) {
if ($layout_block_id !== $content_block->uuid()) {
continue;
}
$content_block->updateBlock($layout_block_configuration);
$content_block->save();
}
}
}
drupal_set_message($this->t('The layout for @label has been saved.', ['@label' => $this->contentEntity->label()]));
}
示例14: testCleanValues
/**
* @covers ::cleanValues
*/
public function testCleanValues()
{
$this->decoratedFormState->cleanValues()->shouldBeCalled();
$this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->cleanValues());
}
示例15: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$form_state->cleanValues();
// The image effect configuration is stored in the 'data' key in the form,
// pass that through for submission.
$effect_data = (new FormState())->setValues($form_state->getValue('data'));
$this->imageEffect->submitConfigurationForm($form, $effect_data);
// Update the original form values.
$form_state->setValue('data', $effect_data->getValues());
$this->imageEffect->setWeight($form_state->getValue('weight'));
if (!$this->imageEffect->getUuid()) {
$this->imageStyle->addImageEffect($this->imageEffect->getConfiguration());
}
$this->imageStyle->save();
drupal_set_message($this->t('The image effect was successfully applied.'));
$form_state->setRedirectUrl($this->imageStyle->urlInfo('edit-form'));
}