Skip to content

Add Form component ref support#2496

Merged
pascalbaljet merged 5 commits intomasterfrom
form-component-ref
Aug 12, 2025
Merged

Add Form component ref support#2496
pascalbaljet merged 5 commits intomasterfrom
form-component-ref

Conversation

@pascalbaljet
Copy link
Copy Markdown
Member

This PR adds programmatic access to Form component methods and state via refs:

<script setup>
import { Form } from '@inertiajs/vue3'
import { ref } from 'vue'

const formRef = ref()

const submitForm = () => {
  formRef.value.submit()
}

const checkState = () => {
  console.log('Is dirty:', formRef.value.isDirty)
  console.log('Has errors:', formRef.value.hasErrors)
  console.log('Errors:', formRef.value.errors)
}
</script>

<template>
  <Form ref="formRef" action="/submit" method="post">
    <input name="email" type="email" />
    <button type="submit">Submit</button>
  </Form>
</template>

@pascalbaljet pascalbaljet merged commit 671c4c3 into master Aug 12, 2025
6 checks passed
@pascalbaljet pascalbaljet deleted the form-component-ref branch August 12, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant