Skip to content
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

how to get value from form with multiple inputs with same name and save in db. #734

Open
ssestantech opened this issue Nov 9, 2022 · 3 comments
Labels

Comments

@ssestantech
Copy link

Describe the bug

how to get value from form with multiple inputs with same name and save in db.

Expected behaviour

how to get value from form with multiple inputs with same name and save in db.

Steps to reproduce the bug

No response

Screenshots

No response

OS

Windows

OS version

window 11

Browser

No response

Masonite Version

4.6.1

Anything else ?

how to get value from form with multiple inputs with same name and save in db.

@ssestantech ssestantech added the bug label Nov 9, 2022
@girardinsamuel
Copy link
Contributor

Hi ! Could you post an example of your HTML form in this issue ?

@ssestantech
Copy link
Author

ssestantech commented Nov 9, 2022

<form class="multisteps-form__form" action="{{url('postform')}}" method="post" enctype="multipart/form-data">
          {{ csrf_field }}
<input type="text" name="childrenname[]">
<input type="text" name="childrenname[]">
</form>

@circulon
Copy link
Contributor

circulon commented Jan 5, 2023

@ssestantech

Your issue has nothing to do with Masonite.
Its due to the name of your fields in the form not being unique.

This same issue will happen with many languages & frameworks when parsing the HTML input fields name parameter.

See here for a complete explanation of your issue and how to solve getting the inputs in grouped by the parent childrenname as a list

https://mattstauffer.com/blog/a-little-trick-for-grouping-fields-in-an-html-form/

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants