I have this simple checkbox.
My problem is, if I select any of the checkbox, it should remain checked after form submission.
<label>
<input type="checkbox" name="services_offered[]" value="water jet cutting"> Water Jet Cutting</label>
<label>
<input type="checkbox" name="services_offered[]" value="plasma cutting"> Plasma Cutting</label>
<label>
<input type="checkbox" name="services_offered[]" value="CNC router cutting"> CNC Router Cutting</label>
I tried to use my code before but no luck,
<?php
function isChecked($value)
{
return (!empty($_REQUEST['services_offered']) && in_array($value,$_REQUEST['services_offered']));
}
<label><input type="checkbox" name="services_offered[]" value="water jet cutting" <?php if(isChecked('water jet cutting')) echo ' checked' ?>> Water Jet Cutting</label>
<label><input type="checkbox" name="services_offered[]" value="plasma cutting" <?php if(isChecked('plasma cutting')) echo ' checked' ?> > Plasma Cutting</label>
<label><input type="checkbox" name="services_offered[]" value="CNC router cutting" <?php if(isChecked('CNC router cutting')) echo ' checked' ?>> CNC Router Cutting</label>
I want it to convert in "laravel way" but I dont know how.
Hope you understand me.
Thanks.
Aucun commentaire:
Enregistrer un commentaire