I'm trying to add a toggle switch to my form (blade template in laravel 9). I pulled the toggle from https://flowbite.com/docs/forms/toggle/, but it was missing the 'name' attribute so I added that myself, and it now appears in the form data, but it's always null.
Here's the code:
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" name="goal" value="" class="sr-only peer">
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
<span class="ml-3 text-sm font-medium text-gray-900 dark:text-gray-300">Goal</span>
</label>
As far as I can tell, the toggle switch doesn't actually change the value of the checkbox at all, but the div set to change based on 'peer' suggests that it is.
I must be missing something really obvious. Any ideas?
Aucun commentaire:
Enregistrer un commentaire