Jump to content

Chris7912

Members
  • Posts

    2
  • Joined

  • Last visited

Chris7912's Achievements

Newbie

Newbie (2/6)

0

Reputation

  1. 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?
×
×
  • Create New...