public function EntityFormProxy::getForm in Lightning Media 8
Same name and namespace in other branches
- 8.4 src/Plugin/EntityBrowser/Widget/EntityFormProxy.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EntityFormProxy::getForm()
- 8.2 src/Plugin/EntityBrowser/Widget/EntityFormProxy.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EntityFormProxy::getForm()
- 8.3 src/Plugin/EntityBrowser/Widget/EntityFormProxy.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EntityFormProxy::getForm()
2 calls to EntityFormProxy::getForm()
- EmbedCode::getForm in src/
Plugin/ EntityBrowser/ Widget/ EmbedCode.php - FileUpload::getForm in src/
Plugin/ EntityBrowser/ Widget/ FileUpload.php
2 methods override EntityFormProxy::getForm()
- EmbedCode::getForm in src/
Plugin/ EntityBrowser/ Widget/ EmbedCode.php - FileUpload::getForm in src/
Plugin/ EntityBrowser/ Widget/ FileUpload.php
File
- src/
Plugin/ EntityBrowser/ Widget/ EntityFormProxy.php, line 81
Class
- EntityFormProxy
- Base class for EB widgets which wrap around an (inline) entity form.
Namespace
Drupal\lightning_media\Plugin\EntityBrowser\WidgetCode
public function getForm(array &$original_form, FormStateInterface $form_state, array $additional_widget_parameters) {
$form = parent::getForm($original_form, $form_state, $additional_widget_parameters);
if (isset($form['actions'])) {
$form['actions']['#weight'] = 100;
}
$form['entity'] = [
'#prefix' => '<div id="entity">',
'#suffix' => '</div>',
'#weight' => 99,
];
$value = $this
->getInputValue($form_state);
if (empty($value)) {
$form['entity']['#markup'] = NULL;
return $form;
}
try {
$entity = $this->helper
->createFromInput($value, $this
->getAllowedBundles($form_state));
} catch (IndeterminateBundleException $e) {
return $form;
}
$form['entity'] += [
'#type' => 'inline_entity_form',
'#entity_type' => $entity
->getEntityTypeId(),
'#bundle' => $entity
->bundle(),
'#default_value' => $entity,
'#form_mode' => $this->configuration['form_mode'],
];
// Without this, IEF won't know where to hook into the widget. Don't pass
// $original_form as the second argument to addCallback(), because it's not
// just the entity browser part of the form, not the actual complete form.
ElementSubmit::addCallback($form['actions']['submit'], $form_state
->getCompleteForm());
return $form;
}