public static function ElementSubmit::attach in Inline Entity Form 8
Attaches the #ief_element_submit functionality to the given form.
Parameters
array $form: The form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
2 calls to ElementSubmit::attach()
- InlineEntityForm::processEntityForm in src/
Element/ InlineEntityForm.php - Builds the entity form using the inline form handler.
- inline_entity_form_form_alter in ./
inline_entity_form.module - Implements hook_form_alter().
File
- src/
ElementSubmit.php, line 25
Class
- ElementSubmit
- Provides #ief_element_submit, the submit version of #element_validate.
Namespace
Drupal\inline_entity_formCode
public static function attach(&$form, FormStateInterface $form_state) {
// attach() is called for each IEF form element, but the callbacks only
// need to be added once per form build.
if (isset($form['#ief_element_submit_attached'])) {
return;
}
$form['#ief_element_submit_attached'] = TRUE;
// Entity form actions.
foreach ([
'submit',
'publish',
'unpublish',
] as $action) {
if (!empty($form['actions'][$action])) {
self::addCallback($form['actions'][$action], $form);
}
}
// Generic submit button.
if (!empty($form['submit'])) {
self::addCallback($form['submit'], $form);
}
}