本文整理汇总了PHP中Drupal\Core\Entity\EntityForm::submitForm方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityForm::submitForm方法的具体用法?PHP EntityForm::submitForm怎么用?PHP EntityForm::submitForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityForm
的用法示例。
在下文中一共展示了EntityForm::submitForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Get an array of strings with the permissions names.
$permissions = array_keys(array_filter($form_state->getValue('permissions')));
$form_state->setValue('permissions', $permissions);
parent::submitForm($form, $form_state);
}
示例3: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$plugin = $this->manager->createInstance($form_state->getValue('key_provider'), []);
$plugin->submitConfigurationForm($form, $form_state);
$form_state->setValue('key_provider_settings', $plugin->getConfiguration());
parent::submitForm($form, $form_state);
}
示例4: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
$target_entity = $form_state->getValue('entity');
$target_bundle = $form_state->getValue('bundle', $target_entity);
$this->entity->set('target_entity_type', $target_entity);
$this->entity->set('target_bundle', $target_bundle);
if ($target_entity !== $target_bundle) {
drupal_set_message($this->t('A entity layout for the @entity entity and @bundle bundle has been created.', ['@entity' => $this->entityLayoutService->getTargetEntityLabel($this->entity), '@bundle' => $this->entityLayoutService->getTargetBundleLabel($this->entity)]));
} else {
drupal_set_message($this->t('A entity layout for the @entity entity has been created.', ['@entity' => $this->entityLayoutService->getTargetEntityLabel($this->entity)]));
}
$form_state->setRedirectUrl($this->entity->toUrl('collection'));
}
示例5: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
$facet_source = $this->getEntity();
drupal_set_message($this->t('Facet source %name has been saved.', ['%name' => $facet_source->label()]));
$form_state->setRedirect('facets.overview');
}
示例6: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Allow the variant to submit the form.
$variant_plugin_values = (new FormState())->setValues($form_state->getValue('variant_settings'));
$this->getVariantPlugin()->submitConfigurationForm($form, $variant_plugin_values);
// Make sure the Panels storage is set correctly before saving.
$this->setPanelsStorage($this->getVariantPlugin());
// Update the original form values.
$form_state->setValue('variant_settings', $variant_plugin_values->getValues());
parent::submitForm($form, $form_state);
}
示例7: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
// Handle the default value.
$default_value = array();
if (isset($form['default_value'])) {
$items = $form['#entity']->get($this->entity->getName());
$default_value = $items->defaultValuesFormSubmit($form['default_value'], $form, $form_state);
}
$this->entity->default_value = $default_value;
}
示例8: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
if (!$this->entity->isNew() || $this->entity->isLocked()) {
$this->submitOverviewForm($form, $form_state);
}
}
示例9: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
/** @var $index \Drupal\search_api\IndexInterface */
$index = $this->getEntity();
$index->setOptions($form_state->getValue('options', array()) + $this->originalEntity->getOptions());
$datasources = $form_state->getValue('datasources', array());
/** @var \Drupal\search_api\Datasource\DatasourceInterface[] $datasource_plugins */
$datasource_plugins = $this->originalEntity->getDatasources(FALSE);
$datasource_configuration = array();
foreach ($datasources as $datasource_id) {
$datasource = $datasource_plugins[$datasource_id];
$datasource_form = !empty($form['datasource_configs'][$datasource_id]) ? $form['datasource_configs'][$datasource_id] : array();
$datasource_form_state = new SubFormState($form_state, array('datasource_configs', $datasource_id));
$datasource->submitConfigurationForm($datasource_form, $datasource_form_state);
$datasource_configuration[$datasource_id] = $datasource->getConfiguration();
}
$index->set('datasource_configs', $datasource_configuration);
// Call submitConfigurationForm() for the (possibly new) tracker.
// @todo It seems if we change the tracker, we would validate/submit the old
// tracker's form using the new tracker. Shouldn't be done, of course.
// Similar above for datasources, though there of course the values will
// just always be empty (because datasources have their plugin ID in the
// form structure).
$tracker_id = $form_state->getValue('tracker', NULL);
if ($this->originalEntity->getTrackerId() == $tracker_id) {
$tracker = $this->originalEntity->getTracker();
} else {
$tracker = $this->trackerPluginManager->createInstance($tracker_id, array('index' => $this->originalEntity));
}
$tracker_form_state = new SubFormState($form_state, array('tracker_config'));
$tracker->submitConfigurationForm($form['tracker_config'], $tracker_form_state);
$index->set('tracker_config', $tracker->getConfiguration());
// Invalidate caches, so this gets picked up by the views wizard.
Cache::invalidateTags(array('views_data'));
// Remove this line when https://www.drupal.org/node/2370365 gets fixed.
Cache::invalidateTags(array('extension:views'));
}
示例10: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
// Add the submitted form values to the text format, and save it.
$format = $this->entity;
foreach ($form_state->getValues() as $key => $value) {
if ($key != 'filters') {
$format->set($key, $value);
} else {
foreach ($value as $instance_id => $config) {
$format->setFilterConfig($instance_id, $config);
}
}
}
$format->save();
// Save user permissions.
if ($permission = $format->getPermissionName()) {
foreach ($form_state->getValue('roles') as $rid => $enabled) {
user_role_change_permissions($rid, array($permission => $enabled));
}
}
$form_state->setRedirect('filter.admin_overview');
return $this->entity;
}
示例11: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
$this->plugin->submitConfigurationForm($form['settings'], $form_state);
}
示例12: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
parent::submitForm($form, $form_state);
/** @var \Drupal\search_api\ServerInterface $server */
$authorization_profile = $this->getEntity();
// Check before loading the provider plugin so we don't throw an exception.
if ($form['provider_config']['#type'] == 'details' && $authorization_profile->hasValidProvider()) {
$provider_form_state = new SubFormState($form_state, array('provider_config'));
$authorization_profile->getProvider()->submitConfigurationForm($form['provider_config'], $provider_form_state);
}
// Check before loading the consumer plugin so we don't throw an exception.
if ($form['consumer_config']['#type'] == 'details' && $authorization_profile->hasValidConsumer()) {
$consumer_form_state = new SubFormState($form_state, array('consumer_config'));
$authorization_profile->getConsumer()->submitConfigurationForm($form['consumer_config'], $consumer_form_state);
}
// @TODO Submit Row forms
if ($form['mappings']) {
$mappings_form_state = new SubFormState($form_state, array('mappings'));
$authorization_profile->getConsumer()->submitRowForm($form['mappings'], $mappings_form_state);
$authorization_profile->getProvider()->submitRowForm($form['mappings'], $mappings_form_state);
// Move provider_mappings to the top level
// @TODO fix this. Why do we have to do it? Why doesn't it work?
$values = $form_state->getValues();
$values['provider_mappings'] = $values['mappings']['provider_mappings'];
unset($values['mappings']['provider_mappings']);
$values['consumer_mappings'] = $values['mappings']['consumer_mappings'];
unset($values['mappings']['consumer_mappings']);
$form_state->setValues($values);
// @TODO shouldn't have to do this. Though the above doesn't work either.
// @TODO should validate beforehand to make sure that we have mappings.
if ($values['provider_mappings']) {
$authorization_profile->setProviderMappings($values['provider_mappings']);
}
if ($values['consumer_mappings']) {
$authorization_profile->setConsumerMappings($values['consumer_mappings']);
}
}
return $authorization_profile;
}
示例13: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$this->getParentPaymentStatusSelector($form_state)->submitSelectorForm($form['parent_id'], $form_state);
parent::submitForm($form, $form_state);
}
示例14: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// Submit plugin configuration if available.
if ($plugin = $this->entity->getEncryptionMethod()) {
if ($plugin instanceof EncryptionMethodPluginFormInterface) {
$plugin_form_state = $this->createPluginFormState($form_state);
$plugin->submitConfigurationForm($form, $plugin_form_state);
$form_state->setValue('encryption_method_configuration', $plugin_form_state->getValues());
}
}
parent::submitForm($form, $form_state);
}
示例15: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
/** @var \Drupal\payment\Plugin\Payment\MethodConfiguration\PaymentMethodConfigurationInterface $payment_method_configuration */
$payment_method_configuration = $form_state->get('payment_method_configuration');
$payment_method_configuration->submitConfigurationForm($form['plugin_form'], $form_state);
parent::submitForm($form, $form_state);
}