public function AddContentByBundle::validate in Add Content by Bundle Views Area Plugin 1.x
Validate that the plugin is correct and can be saved.
Return value
An array of error strings to tell the user what is wrong with this plugin.
Overrides HandlerBase::validate
File
- src/
Plugin/ views/ area/ AddContentByBundle.php, line 165
Class
- AddContentByBundle
- Defines an area plugin to display a bundle-specific node/add link.
Namespace
Drupal\add_content_by_bundle\Plugin\views\areaCode
public function validate() {
$errors = parent::validate();
// Validate that the specified form mode exists for the specified bundle.
if ($this->options['form_mode']) {
$entity_type = $this->view
->getBaseEntityType()
->id();
$form_modes = \Drupal::service('entity_display.repository')
->getFormModeOptionsByBundle($entity_type, $this->options['bundle']);
if (!isset($form_modes[$this->options['form_mode']])) {
$errors[] = $this
->t('%current_display: The %form_mode form display is not defined for the %bundle type.', [
'%current_display' => $this->displayHandler->display['display_title'],
'%form_mode' => $this->options['form_mode'],
'%bundle' => $this->options['bundle'],
]);
return $errors;
}
}
}