ArtiGrid
Custom Form Buttons
This example demonstrates how to customize the buttons displayed in ArtiGrid forms. You can modify the label, CSS class, visibility, and appearance of the default form buttons without changing the internal form structure.
Using formButtons(), you can easily customize the native buttons such as
save and cancel. You can change their labels and styles,
or hide a button completely when it is not required.
ArtiGrid also allows you to add your own buttons with addFormButton().
Custom buttons can include icons, JavaScript actions, and additional HTML attributes,
giving you full control over their behavior.
For example, a custom button can open another page, execute a JavaScript function,
or close the modal form using Bootstrap attributes such as
data-bs-dismiss="modal".
This makes it possible to adapt ArtiGrid forms to different workflows while keeping the implementation simple and fully customizable.
<?php
$grid = new ArtiGrid();
$grid->table('users')
->template('bootstrap5')
// Rename / restyle the native buttons
->formButtons([
'save' => ['label' => 'Register user', 'class' => 'btn btn-success'],
'cancel' => ['show' => false], // hide cancel
])
// Custom button
->addFormButton('View help', [
'class' => 'btn btn-outline-info',
'icon' => '<i class="fa fa-circle-question"></i>',
'onclick' => "window.open('http://google.com','_blank')",
])
->addFormButton('Close', [
'class' => 'btn btn-light',
'attrs' => ['data-bs-dismiss' => 'modal'], // close the popup
]);
echo $grid->render();
?>