Home › Other plugins › Gravity Forms Auto Complete (+address field) › Save users input
- This topic has 4 replies, 3 voices, and was last updated 3 years ago by
Admin.
-
AuthorPosts
-
Daniels
ParticipantNovember 29, 2021 at 2:10 am #13525Hi,
There is an option “Allow adding new option”, it lets users add a new option to Autocomplete field, but I noticed that it doesn’t save that option so other users can later select it.
Is there a way to save newly created options so they can later be shown to other users?Thanks,
DanielsAdmin
KeymasterDecember 3, 2021 at 5:28 am #13528Hello Daniel,
Yes, you’re right, the new option will not be available for other users.
But we could add such a behavior as a custom task.
Please send a request to our support center if you’re interested.Thanks.
James H
ParticipantFebruary 16, 2022 at 10:07 pm #13645Like Daniel I assumed that this was part of the logic.
Has this since been added so that newly created options are stored for all users?
James
Daniels
ParticipantFebruary 16, 2022 at 10:58 pm #13646The support here isn’t very helpful.
I couldn’t wait for them to add this option so i used a gravity forms hook to loop through all answers checking if its autocomplete field and if it is then save it somewhere where i need it.
If you know something about coding here is my answer:
/*Save new companies after successful form submission*/ add_action( 'gform_after_submission', 'action_gform_after_submission', 10, 2 ); function action_gform_after_submission( $entry, $form ) { $companies = getSurveyCompanies(); $new_companies = array(); foreach ( $form['fields'] as $field ) { if($field->get_input_type() == 'autocomplete'){ $value = htmlspecialchars(rgar( $entry, (string) $field->id )); if($value){ $is_in_db = false; if(strlen($value) > 170){ $value = substr($value,0, 170); } foreach ($companies as $company){ if($company->name == $value){ $is_in_db = true; break; } } if(!$is_in_db){ array_push($new_companies, $value); } } } } if(!empty($new_companies)){ foreach ($new_companies as $company){ if(strlen($company) > 3){ addSurveyCompany($company); } } } } /*END Save new companies after successful form submission*/Admin
Keymaster -
AuthorPosts
- You must be logged in to reply to this topic.