本文整理汇总了PHP中Drupal\Core\Form\FormStateInterface::setRebuild方法的典型用法代码示例。如果您正苦于以下问题:PHP FormStateInterface::setRebuild方法的具体用法?PHP FormStateInterface::setRebuild怎么用?PHP FormStateInterface::setRebuild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormStateInterface
的用法示例。
在下文中一共展示了FormStateInterface::setRebuild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchContextMode
/**
* Submit callback: switch a context to data selecor or direct input mode.
*/
public function switchContextMode(array &$form, FormStateInterface $form_state)
{
$element_name = $form_state->getTriggeringElement()['#name'];
$mode = $form_state->get($element_name);
$switched_mode = $mode == 'selector' ? 'input' : 'selector';
$form_state->set($element_name, $switched_mode);
$form_state->setRebuild();
}
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
if ($form_state->getTriggeringElement()['#name'] == 'select_id_submit') {
$form_state->set('default_type', $form_state->getValue('id'));
$form_state->setRebuild();
} else {
parent::submitForm($form, $form_state);
}
}
示例3: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$values = $form_state->getValues();
$taxType = $this->taxTypeImporter->createTaxType($values['tax_type']);
try {
$taxType->save();
drupal_set_message($this->t('Imported the %label tax type.', ['%label' => $taxType->label()]));
$triggeringElement['#name'] = $form_state->getTriggeringElement();
if ($triggeringElement['#name'] == 'import_and_new') {
$form_state->setRebuild();
} else {
$form_state->setRedirect('entity.commerce_tax_type.collection');
}
} catch (\Exception $e) {
drupal_set_message($this->t('The %label tax type was not imported.', ['%label' => $taxType->label()]), 'error');
$this->logger('commerce_tax')->error($e);
$form_state->setRebuild();
}
}
示例4: removeLineItem
/**
* Order pane submit callback: Remove a line item from an order.
*/
public function removeLineItem($form, FormStateInterface $form_state)
{
$order =& $form_state->get('order');
$triggering_element = $form_state->getTriggeringElement();
$line_item_id = intval($triggering_element['#return_value']);
uc_order_delete_line_item($line_item_id);
$order->line_items = $order->getLineItems();
$form_state->setRebuild();
}
示例5: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$form_connection_settings = $form_state->getValue('connection_settings');
switch ($form_state->getTriggeringElement()['#name']) {
case 'process_updates':
// Save the connection settings to the DB.
$filetransfer_backend = $form_connection_settings['authorize_filetransfer_default'];
// If the database is available then try to save our settings. We have
// to make sure it is available since this code could potentially (will
// likely) be called during the installation process, before the
// database is set up.
try {
$connection_settings = array();
foreach ($form_connection_settings[$filetransfer_backend] as $key => $value) {
// We do *not* want to store passwords in the database, unless the
// backend explicitly says so via the magic #filetransfer_save form
// property. Otherwise, we store everything that's not explicitly
// marked with #filetransfer_save set to FALSE.
if (!isset($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save'])) {
if ($form['connection_settings'][$filetransfer_backend][$key]['#type'] != 'password') {
$connection_settings[$key] = $value;
}
} elseif ($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save']) {
$connection_settings[$key] = $value;
}
}
// Set this one as the default authorize method.
$this->config('system.authorize')->set('filetransfer_default', $filetransfer_backend);
// Save the connection settings minus the password.
$this->config('system.authorize')->set('filetransfer_connection_settings_' . $filetransfer_backend, $connection_settings);
$filetransfer = $this->getFiletransfer($filetransfer_backend, $form_connection_settings[$filetransfer_backend]);
// Now run the operation.
$this->runOperation($filetransfer);
} catch (\Exception $e) {
// If there is no database available, we don't care and just skip
// this part entirely.
}
break;
case 'enter_connection_settings':
$form_state->setRebuild();
break;
case 'change_connection_type':
$form_state->setRebuild();
$form_state->unsetValue(array('connection_settings', 'authorize_filetransfer_default'));
break;
}
}
示例6: save
public function save(array $form, FormStateInterface $form_state) {
if ($this->entity->getEFormType()->preview_page) {
$form_state->set('preview_entity', $this->entity);
$form_state->setRebuild();
}
return parent::save($form, $form_state);
}
示例7: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
try {
$entity = $this->entity;
// Save as a new revision if requested to do so.
if (!$form_state->isValueEmpty('revision')) {
$entity->setNewRevision();
}
$is_new = $entity->isNew();
$entity->save();
if ($is_new) {
$message = t('%entity_type @id has been created.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()));
} else {
$message = t('%entity_type @id has been updated.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()));
}
drupal_set_message($message);
if ($entity->id()) {
$entity_type = $entity->getEntityTypeId();
$form_state->setRedirect("entity.{$entity_type}.edit_form", array($entity_type => $entity->id()));
} else {
// Error on save.
drupal_set_message(t('The entity could not be saved.'), 'error');
$form_state->setRebuild();
}
} catch (\Exception $e) {
\Drupal::state()->set('entity_test.form.save.exception', get_class($e) . ': ' . $e->getMessage());
}
}
示例8: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$currency_code = $form_state->getValue('currency_code');
$currency = $this->importer->import($currency_code);
drupal_set_message($this->t('Imported the %label currency.', ['%label' => $currency->label()]));
$form_state->setRebuild();
}
示例9: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$currency_codes = $form_state->getValue('currency_codes');
foreach ($currency_codes as $currency_code) {
$this->importer->import($currency_code);
}
drupal_set_message($this->t('Imported the selected currencies.'));
$form_state->setRebuild();
}
示例10: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$form_state->setCached();
$form_state->setRebuild();
$database_class = $form_state->get('database_class');
if ($form_state->get('database') instanceof $database_class) {
$form_state->set('database_connection_found', TRUE);
}
}
示例11: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
if ($form_state->getValue('add_files')) {
$path = drupal_get_path('module', 'system');
$attached = array('#attached' => array('css' => array($path . '/css/system.admin.css' => array()), 'js' => array(0 => array('type' => 'setting', 'data' => array('ajax_forms_test_lazy_load_form_submit' => 'executed')), $path . '/system.js' => array())));
drupal_render($attached);
drupal_process_attached($attached);
}
$form_state->setRebuild();
}
示例12: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
if ($this->step < 3) {
$form_state->setRebuild();
$this->step++;
} else {
parent::submitForm($form, $form_state);
/*$this->config('multi_step.multi_step_form_config')
->set('model', $form_state->getValue('model'))
->set('body_style', $form_state->getValue('body_style'))
->set('gas_mileage', $form_state->getValue('gas_mileage'))
->save();*/
}
}
示例13: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
batch_test_stack(NULL, TRUE);
$step = $form_state->get('step');
switch ($step) {
case 1:
batch_set(_batch_test_batch_1());
break;
case 2:
batch_set(_batch_test_batch_2());
break;
}
if ($step < 2) {
$form_state->set('step', ++$step);
$form_state->setRebuild();
}
$form_state->setRedirect('batch_test.redirect');
}
示例14: 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);
}
示例15: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
$workspace = $this->entity;
$insert = $workspace->isNew();
$workspace->save();
$info = ['%info' => $workspace->label()];
$context = array('@type' => $workspace->bundle(), $info);
$logger = $this->logger('multiversion');
if ($insert) {
$logger->notice('@type: added %info.', $context);
drupal_set_message($this->t('Workspace %info has been created.', $info));
} else {
$logger->notice('@type: updated %info.', $context);
drupal_set_message($this->t('Workspace %info has been updated.', $info));
}
if ($workspace->id()) {
$form_state->setValue('id', $workspace->id());
$form_state->set('id', $workspace->id());
$form_state->setRedirectUrl($workspace->urlInfo('collection'));
} else {
drupal_set_message($this->t('The workspace could not be saved.'), 'error');
$form_state->setRebuild();
}
}