Trying to assign the proper route ID to my post request but I'm lost as to why it's not working.
I cannot seem to access accountId inside of my submit_new_property function.
Any advice?
AccountController:
public function index($id) {
return Inertia::render('Account', [
'accountId' => $id,
'accounts' => Account::paginate(100)->through(fn($account) => [
'id' => $account->id,
'name' => $account->name,
]),
]);
}
Account.vue:
<script setup>
import { ref } from 'vue';
import { useForm } from '@inertiajs/inertia-vue3';
import AppLayout from '@/Layouts/AppLayout.vue';
import Welcome from '@/Components/Welcome.vue';
import DialogModal from '@/Components/DialogModal.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import SecondaryButton from '@/Components/SecondaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { reactive } from 'vue';
let create_new_property = reactive({
name: '',
});
let submit_new_property = () => {
// Submit new property creation
Inertia.post('/accounts/{accountId}', create_new_property);
};
</script>
<form @submit.prevent="submit_new_property" id="create_new_property">
<label for="new_property_name">Property Name</label>
<TextInput
v-model="create_new_property.name"
id="new_property_name"
ref="textInput"
type="text"
class="mt-1 block w-full"
name="new_property_name"
placeholder="New Property Name"
required="required"
/>
</form>
<script >
import { Link } from '@inertiajs/inertia-vue3';
import { Inertia } from '@inertiajs/inertia';
export default {
components: { Link },
props: {
accountId: String,
accounts: Object,
},
};
</script>