Chris7912 Posted January 8, 2024 Share Posted January 8, 2024 Hello! I have a Question regarding the procesInputDone hook. After Submitting a certain form, i want to get all the Fields of that form and turn them into a Json File. My first idea was to approach the Code like this: $wire->addHookAfter('FormBuilderProcessor::processInputDone', function(HookEvent $event) { $form = $event->arguments(0); if ($form->isSubmitted()) { $formValues = $form->getAll(); $formData = []; foreach ($form->getAll() as $field) { $fieldName = $field->name; $formData[$fieldName] = $form->getChildByName($fieldName)->value; } if (!empty($formData)) { $jsonData = json_encode($formData); $jsonFileName = uniqid() . '.json'; $jsonFilePath = wire('config')->paths->assets . 'json/' . $jsonFileName; file_put_contents($jsonFilePath, $jsonData); } } ... The only problem with this is, that a Pagebreak in the Form results in the JSON file only having the last page entries. My only question is how to avoid this issue or is there a better approach to getting a json file ready of the form submit in a hook? Link to comment Share on other sites More sharing options...
poljpocket Posted January 15, 2024 Share Posted January 15, 2024 Since this is FormBuilder, you should move this to the paid FormBuilder forum. If you have an active license, you can post there and should get support. Link to comment Share on other sites More sharing options...
Chris7912 Posted January 22, 2024 Author Share Posted January 22, 2024 Alright, i will do just that, Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now