public function DynamicLayoutController::addRow in Dynamic Layouts 8
Callback for adding a row.
Parameters
string $dynamic_layout_id: The dynamic layout id.
Return value
object The ajax response.
1 string reference to 'DynamicLayoutController::addRow'
File
- src/
Controller/ DynamicLayoutController.php, line 192
Class
- DynamicLayoutController
- DynamicLayoutController class.
Namespace
Drupal\dynamic_layouts\ControllerCode
public function addRow($dynamic_layout_id) {
$response = new AjaxResponse();
/* @var \Drupal\dynamic_layouts\DynamicLayoutInterface $config_entity */
if ($config_entity = $this->entityTypeManager
->getStorage(Constants::DYNAMIC_LAYOUT)
->load($dynamic_layout_id)) {
// Add a row.
$config_entity
->addRow();
// Save the 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(Constants::DYNAMIC_LAYOUT_FORM_CLASS, $layout_form));
}
return $response;
}