-
Notifications
You must be signed in to change notification settings - Fork 537
feat: give access to underlying data as object and as form data object #2605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pascalbaljet
merged 5 commits into
inertiajs:master
from
MeiKatz:feat/get-current-values-from-form
Oct 28, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3c33fd5
feat: give access to underlying data as object and as form data object
MeiKatz 519f408
Merge branch 'master' into pr/2605
pascalbaljet 45e576a
Tests + types
pascalbaljet 964640f
Update DataMethods.svelte
pascalbaljet 01c4d2c
Fix Svelte config
pascalbaljet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/react/test-app/Pages/FormComponent/DataMethods.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { Form } from '@inertiajs/react' | ||
|
|
||
| export default () => { | ||
| return ( | ||
| <div> | ||
| <h1>Test getData() and getFormData() Methods</h1> | ||
|
|
||
| <Form> | ||
| {({ getData, getFormData }) => ( | ||
| <> | ||
| <input type="text" name="name" id="name" /> | ||
|
|
||
| <button | ||
| type="button" | ||
| onClick={() => { | ||
| const data = getData() | ||
| console.log('getData result:', data) | ||
| }} | ||
| > | ||
| Test getData() | ||
| </button> | ||
|
|
||
| <button | ||
| type="button" | ||
| onClick={() => { | ||
| const formData = getFormData() | ||
| console.log('getFormData entries:', Object.fromEntries(formData.entries())) | ||
| }} | ||
| > | ||
| Test getFormData() | ||
| </button> | ||
| </> | ||
| )} | ||
| </Form> | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/svelte/test-app/Pages/FormComponent/DataMethods.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <script lang="ts"> | ||
| import type { FormDataConvertible } from '@inertiajs/core' | ||
| import { Form } from '@inertiajs/svelte' | ||
|
|
||
| function testGetData(getData: () => Record<string, FormDataConvertible>) { | ||
| const data = getData() | ||
| console.log('getData result:', data) | ||
| } | ||
|
|
||
| function testGetFormData(getFormData: () => FormData) { | ||
| const formData = getFormData() | ||
|
|
||
| console.log('getFormData entries:', Object.fromEntries(formData.entries())) | ||
| } | ||
| </script> | ||
|
|
||
| <div> | ||
| <h1>Test getData() and getFormData() Methods</h1> | ||
|
|
||
| <Form let:getData let:getFormData> | ||
| <input type="text" id="name" name="name" /> | ||
|
|
||
| <button type="button" on:click={() => testGetData(getData)}> Test getData() </button> | ||
|
|
||
| <button type="button" on:click={() => testGetFormData(getFormData)}> Test getFormData() </button> | ||
| </Form> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/vue3/test-app/Pages/FormComponent/DataMethods.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <script setup lang="ts"> | ||
| import { FormDataConvertible } from '@inertiajs/core' | ||
| import { Form } from '@inertiajs/vue3' | ||
|
|
||
| function testGetData(getData: () => Record<string, FormDataConvertible>) { | ||
| const data = getData() | ||
| console.log('getData result:', data) | ||
| } | ||
|
|
||
| function testGetFormData(getFormData: () => FormData) { | ||
| const formData = getFormData() | ||
| console.log('getFormData entries:', Object.fromEntries(formData.entries())) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <div> | ||
| <h1>Test getData() and getFormData() Methods</h1> | ||
|
|
||
| <Form v-slot="{ getData, getFormData }"> | ||
| <input id="name" type="text" name="name" /> | ||
|
|
||
| <button type="button" @click="testGetData(getData)">Test getData()</button> | ||
|
|
||
| <button type="button" @click="testGetFormData(getFormData)">Test getFormData()</button> | ||
| </Form> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay,
consoleMessageswas the missing piece. I didn't know about this and that I could listen toconsole.log()this way.