Home › Forums › General Issues › Reusing a form like a repeater
Hello everyone!
I’m trying to use a form multiple times on one page, to capture a specific input for different labels, similarly to what a repeater does.
The reason for this is that I am displaying information on a certain product in a table, and need to retrieve some user input next to it, for each product. This is why I cannot use a repeater.
My question is, how would I go about retrieving the input values from the fields? I know that me messing with the way that ACF works will most likely result in ACF not providing the values out of the box, but I only need the values at submission time, not persistent.
I have tried to alter the name
of the field in the load_field
filter, but it doesn’t seem to change the name
attribute in the emitted HTML source.
Anny ideas on how to accomplish this? Getting the values with the $_POST
object would suffice as well.
Assuming that you are using WooCommerce, I would be looking for an alternate method of adding custom fields to the WC checkout process other than using ACF. I would guess that there is some type of plugin that will let you add fields for collecting information like this, but I am not familiar enough with it to know for sure.
A quick search turned up the following
https://woocommerce.com/products/product-add-ons/
https://www.modernmarketingpartners.com/2014/11/25/add-sizes-woocommerce/
Is there a reason why ACF wouldn’t be the best here? I really enjoy the visuals and the customizability of the different input elements.
I could also use bare HTML, but ACF would just look nicer.
I’ve already briefly looked into WooCommerce addons, but I feel like those lack ability to customize the fields sufficiently, unlike ACF.
Going to be honest, I don’t know enough about WC to help you with this. If you want ACF fields in the admin I would still look into how to add custom fields to the WC checkout that are independent of ACF and then I would then figure out how to do 2 things.
The answers to how to do those 2 things would probably dictate what type of fields you would use and how you would use them in ACF.
While I do use ACF for nearly everything, sometimes it is not the right tool for the job or requires a lot of work to make it do something out of the box.
Alright, that makes sense, thank you so much for your detailed replies.
So there is no “easy” way to simply change the name
property in the emitted HTML code of a field? Or no way at all?
ACF uses the field keys as the input names. If you change them then ACF will be unable to save the values. You would need to create your own fields and then figure out how to update the ACF fields yourself.
I’m aware that ACF won’t be able to save them, but I can still capture them myself during the POST request of the submission. I was just wondering if I could change the name under which the fields are being submit, but I’ll go with a custom HTML form now.
Thank you so much for your help!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.