public function EditColumnModalForm::updateValues in Dynamic Layouts 8
Update the entity values.
Parameters
int $entity_id: The entity id.
int $row_id: The row id.
int $column_id: The column id.
object $form_state: The form state.
object $response: The ajax response.
1 call to EditColumnModalForm::updateValues()
File
- src/
Form/ EditColumnModalForm.php, line 211
Class
- EditColumnModalForm
- EditColumnModalForm class.
Namespace
Drupal\dynamic_layouts\FormCode
public function updateValues($entity_id, $row_id, $column_id, $form_state, $response) {
/* @var \Drupal\dynamic_layouts\DynamicLayoutInterface $config_entity */
if ($config_entity = $this->entityTypeManager
->getStorage('dynamic_layout')
->load($entity_id)) {
// Set the column classes.
if ($column_classes = $form_state
->getValue('custom_column_classes')) {
// Convert comma separated to array & trim spaces.
$column_classes = array_map('trim', array_filter(explode(',', $column_classes)));
$config_entity
->setCustomColumnClasses($row_id, $column_id, $column_classes);
}
// Set the column name.
$column_name = $form_state
->getValue('column_name');
$config_entity
->setColumnName($row_id, $column_id, $column_name);
// Set the column width number.
if ($new_column_width_number = $form_state
->getValue('column_width_number')) {
$old_column_width_number = $config_entity
->getColumnWidthNumber($row_id, $column_id);
if ($new_column_width_number != $old_column_width_number) {
$config_entity
->setCustomColumnWidthNumber($row_id, $column_id, $new_column_width_number);
}
}
// Save the config entity.
$config_entity
->save();
// Replace the layout form with newly updated values.
/* @var \Drupal\dynamic_layouts\Form\DynamicLayoutForm $layout_form */
$layout_form = $this->entityFormBuilder
->getForm($config_entity);
$response
->addCommand(new ReplaceCommand('.dynamic-layout-form', $layout_form));
}
}