public function WidgetBase::getForm in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/WidgetBase.php \Drupal\entity_browser\WidgetBase::getForm()
Returns widget form.
Parameters
array $original_form: Entire form bult up to this point. Form elements for widget should generally not be added directly to it but returned from funciton as a separated unit.
\Drupal\Core\Form\FormStateInterface $form_state: Form state object.
array $additional_widget_parameters: Additional parameters that we want to pass to the widget.
Return value
array Form structure.
Overrides WidgetInterface::getForm
5 calls to WidgetBase::getForm()
- EntityForm::getForm in modules/
entity_form/ src/ Plugin/ EntityBrowser/ Widget/ EntityForm.php - Returns widget form.
- MultipleSubmitTestWidget::getForm in tests/
modules/ entity_browser_test/ src/ Plugin/ EntityBrowser/ Widget/ MultipleSubmitTestWidget.php - Returns widget form.
- PagerTestWidget::getForm in tests/
modules/ entity_browser_test/ src/ Plugin/ EntityBrowser/ Widget/ PagerTestWidget.php - Returns widget form.
- Upload::getForm in src/
Plugin/ EntityBrowser/ Widget/ Upload.php - Returns widget form.
- View::getForm in src/
Plugin/ EntityBrowser/ Widget/ View.php - Returns widget form.
6 methods override WidgetBase::getForm()
- DummyWidget::getForm in tests/
modules/ entity_browser_test/ src/ Plugin/ EntityBrowser/ Widget/ DummyWidget.php - Returns widget form.
- EntityForm::getForm in modules/
entity_form/ src/ Plugin/ EntityBrowser/ Widget/ EntityForm.php - Returns widget form.
- MultipleSubmitTestWidget::getForm in tests/
modules/ entity_browser_test/ src/ Plugin/ EntityBrowser/ Widget/ MultipleSubmitTestWidget.php - Returns widget form.
- PagerTestWidget::getForm in tests/
modules/ entity_browser_test/ src/ Plugin/ EntityBrowser/ Widget/ PagerTestWidget.php - Returns widget form.
- Upload::getForm in src/
Plugin/ EntityBrowser/ Widget/ Upload.php - Returns widget form.
File
- src/
WidgetBase.php, line 113
Class
- WidgetBase
- Base class for widget plugins.
Namespace
Drupal\entity_browserCode
public function getForm(array &$original_form, FormStateInterface $form_state, array $additional_widget_parameters) {
$form = [];
if ($form_state
->has([
'entity_browser',
'widget_context',
])) {
$this
->handleWidgetContext($form_state
->get([
'entity_browser',
'widget_context',
]));
}
// Check if widget supports auto select functionality and expose config to
// front-end javascript.
$autoSelect = FALSE;
if ($this
->getPluginDefinition()['auto_select']) {
$autoSelect = $this->configuration['auto_select'];
$form['#attached']['drupalSettings']['entity_browser_widget']['auto_select'] = $autoSelect;
}
// In case of auto select, widget will handle adding entities in JS.
if (!$autoSelect) {
$form['actions'] = [
'#type' => 'actions',
'submit' => [
'#type' => 'submit',
'#value' => $this->configuration['submit_text'],
'#eb_widget_main_submit' => TRUE,
'#attributes' => [
'class' => [
'is-entity-browser-submit',
],
],
'#button_type' => 'primary',
],
];
}
return $form;
}