Use these helpers to bridge CodeIgniter 4 validation, old input, and database results with the package Cells.
Load the helper with:
helper('bootstrap_cells');bootstrap_cell_validation_errors($validation): normalize CI4 validation errors to an arraybootstrap_cell_validation_item($item, $validation): enrich one field config withstate=invalidandinvalidFeedbackbootstrap_cell_validation_items($items, $validation): apply the same mapping to a list of field configsbootstrap_cell_validation_alert($validation): generate anAlertCellpayload for a validation summary
Example:
helper('bootstrap_cells');
$alert = bootstrap_cell_validation_alert(service('validation'));
if ($alert !== []) {
echo view_cell(\domProjects\CodeIgniterBootstrap\Cells\AlertCell::class, $alert);
}bootstrap_cell_form_old_value($field, $oldInput): resolve an old value from CI4 or an explicit arraybootstrap_cell_form_item($item, $validation, $oldInput): enrich oneFormCellitem with old value,selected,checked, and validation statebootstrap_cell_form_items($items, $validation, $oldInput): apply the same mapping to a list ofFormCellitemsbootstrap_cell_form_payload($items, $validation, $oldInput, $form): generate a ready-to-use payload forFormCell
Example:
helper('bootstrap_cells');
$form = bootstrap_cell_form_payload([
['name' => 'email', 'label' => 'Email'],
['name' => 'password', 'label' => 'Password', 'type' => 'password'],
], service('validation'));
echo view_cell(\domProjects\CodeIgniterBootstrap\Cells\FormCell::class, $form + [
'classes' => 'row g-3',
]);bootstrap_cell_table_payload($result, $options): build a ready-to-useTableCellpayload from a CI4 Result or an array of rowsbootstrap_cell_table_headers($fieldNames, $options): build normalized table headersbootstrap_cell_table_rows($rows, $options): build normalized table rows, including optional actionsbootstrap_cell_humanize($value): convert a field name likefirst_nametoFirst Name
Example:
helper('bootstrap_cells');
$table = bootstrap_cell_table_payload($query->get(), [
'hidden' => ['id'],
'actions' => static fn (array $row): array => [
['label' => 'Edit', 'href' => '/users/' . $row['id'] . '/edit'],
],
'responsive' => true,
'stacked' => true,
]);
echo view_cell(\domProjects\CodeIgniterBootstrap\Cells\TableCell::class, $table);