public function DynamicLayoutController::deleteRow in Dynamic Layouts 8
Callback for opening the modal form.
Parameters
string $dynamic_layout_id: The dynamic layout id.
int $row_id: The row number we need to delete.
Return value
object The ajax response.
1 string reference to 'DynamicLayoutController::deleteRow'
File
- src/
Controller/ DynamicLayoutController.php, line 161
Class
- DynamicLayoutController
- DynamicLayoutController class.
Namespace
Drupal\dynamic_layouts\ControllerCode
public function deleteRow($dynamic_layout_id, $row_id) {
$response = new AjaxResponse();
/* @var \Drupal\dynamic_layouts\DynamicLayoutInterface $config_entity */
if ($config_entity = $this->entityTypeManager
->getStorage(Constants::DYNAMIC_LAYOUT)
->load($dynamic_layout_id)) {
// Delete the specific row from the config entity.
$config_entity
->deleteRow($row_id);
// 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;
}