freekdz
add input to form
Please how can add the input checkbox data in my state form
"I want to add the selected IDs to the state when I click the 'Add' button, in order to subsequently add all the forms to the table."
if ($isMultiline) {
Step::make('Disponibilites')
->schema([
Placeholder::make('')
->content(function () {
$disponibiliteRecords = Disponibilites::all();
echo '<table>';
echo '<tr>';
$count = 0;
foreach ($disponibiliteRecords as $disponibilite) {
echo '<td>';
echo '<p style="margin-right:130px;"></p>';
echo '<p style="margin-bottom:20px;"></p>';
echo '<p>'. $disponibilite->code .'</p>';
echo '<p><img src="' . asset('storage/uploads/'.$disponibilite->image) . '" alt="Image"></img></p>';
echo '<p>' . $disponibilite->commune_name . '</p>';
echo '<p>' . $disponibilite->adresse . '</p>';
echo '<input type="checkbox" data-id="' . $disponibilite->id . '">';
echo '</td>';
$count++;
if ($count % 3 === 0) {
echo '</tr><tr>'; // Nouvelle ligne après chaque 2e élément
}
}
// Fermer la dernière ligne si nécessaire
if ($count % 3 !== 0) {
echo '</tr>';
}
echo '</table>';
}),
Actions::make([
Action::make('Ajouter')
->icon('heroicon-m-x-mark')
->action(function (Set $set, $state) {
dd($state);
}),
]),
]);
}
14 replies