public function DynamicLayoutForm::setFormValues in Dynamic Layouts 8
1 call to DynamicLayoutForm::setFormValues()
- DynamicLayoutForm::save in src/
Form/ DynamicLayoutForm.php - Form submission handler for the 'save' action.
File
- src/
Form/ DynamicLayoutForm.php, line 398
Class
- DynamicLayoutForm
- Form controller for the DynamicLayout entity edit forms.
Namespace
Drupal\dynamic_layouts\FormCode
public function setFormValues($general_settings, DynamicLayoutInterface $entity, $entity_is_new) {
// Set layout values in entity.
if (isset($general_settings['label']) && $general_settings['label']) {
$entity
->set('label', trim($general_settings['label']));
}
if (isset($general_settings['id']) && $general_settings['id']) {
$entity
->set('id', trim($general_settings['id']));
}
if (isset($general_settings[Constants::CATEGORY]) && $general_settings[Constants::CATEGORY]) {
$entity
->set(Constants::CATEGORY, trim($general_settings[Constants::CATEGORY]));
}
// When a new entity is made, these classes are set in addStartingRows().
// So only set these here if entity is not new.
if (!$entity_is_new) {
if (isset($general_settings[Constants::DEFAULT_COLUMN_CLASS]) && $general_settings[Constants::DEFAULT_COLUMN_CLASS]) {
$entity
->setDefaultColumnClass(trim($general_settings[Constants::DEFAULT_COLUMN_CLASS]));
}
if (isset($general_settings[Constants::DEFAULT_ROW_CLASS]) && $general_settings[Constants::DEFAULT_ROW_CLASS]) {
$entity
->setDefaultRowClass(trim($general_settings[Constants::DEFAULT_ROW_CLASS]));
}
}
$entity
->save();
}