protected function EntityViewDisplayAlterer::addSmartTitleBuilder in Smart Title 8
Add Smart Title checkbox to the entity view display form.
Parameters
array $form: The renderable array of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The FormState object.
1 call to EntityViewDisplayAlterer::addSmartTitleBuilder()
- EntityViewDisplayAlterer::addSmartTitle in src/
EntityViewDisplayAlterer.php - Adds Smart Title to the entity form.
File
- src/
EntityViewDisplayAlterer.php, line 299
Class
- EntityViewDisplayAlterer
- Entity view display form alterer class for Smart Title.
Namespace
Drupal\smart_titleCode
protected function addSmartTitleBuilder(array &$form, FormStateInterface $form_state) {
if (!$form_state
->getFormObject() instanceof EntityFormInterface) {
return;
}
$entity = $form_state
->getFormObject()
->getEntity();
if (!$entity instanceof EntityViewDisplayInterface) {
return;
}
$form['smart_title'] = [
'#type' => 'details',
'#title' => $this
->t('Smart Title'),
'#group' => 'additional_settings',
];
$form['smart_title']['smart_title__enabled'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Make entity title configurable'),
'#description' => $this
->t('Check this box if you would like a configurable entity label for this view mode.'),
'#default_value' => $entity
->getThirdPartySetting('smart_title', 'enabled', FALSE),
];
$form['#entity_builders'][] = [
get_class($this),
'smartTitleBuilder',
];
}