It will read from the database and put an appropriate check in the checkbox (or leave it blank), but I can't get it to update the database when the user checks a checkbox. The other fields work, they update to the database.
<template>
<form>
<div>
<div @input="update">
<input v-model="form.month" type="text" />
<input v-model="form.day_deposited" type="text" />
<input v-model="form.description" type="text" />
<input v-model="form.amount" type="text" />
<input v-model="form.paid" type="checkbox" true-value="1" false-value="0" />
<Link :href="`/income/${props.income.id}`" method="DELETE" as="button" preserve-scroll>Delete</Link>
</div>
</div>
</form>
</template>
<script setup>
import { useForm } from '@inertiajs/vue3'
import { Link } from '@inertiajs/vue3'
const props = defineProps({
income: Object
})
const form = useForm({
id: props.income.id,
month: props.income.month,
day_deposited: props.income.day_deposited,
description: props.income.description,
amount: props.income.amount,
paid: props.income.paid,
})
const update = () => form.put(`/income/${props.income.id}`, {preserveScroll:true})
</script>
true-valueandfalse-valueattributes. You can work with 1 and 0 though, so this is likely a backend issue. What does your controller look like? Are you updating a database record via its model? If so, have you addedpaidto the$protectedproperties array? Have you casted the property to a boolean? Is your database column setup correctly? We need more information to help you.