Is it possible to display form results in admin or a frontend page?

@eskah,

I have no prior hands-on experience with FlexObjects, but the following seems to be working:

  • Follow the Introduction on FlexObjects
    • Enable ‘Contacts’ directory in FlexObjects plugin.
    • Install sample data.
    • Have a look at the Contacts in Admin
  • Create a plain plugin using $ bin/plugin devtools new-plugin.
    • Subscribe to event onFormProcessed
    • Add function onFormProcessed
      public function onFormProcessed(Event $event)
      {
        /** @var Form */
        $form = $event['form'];
        $action = $event['action'];
      
        if ($form->name == 'contacts' && $action == 'addContact') {
          /** @var Flex */
          $flex = $this->grav['flex'];
          /** @var FlexDirectory */
          $dir = $flex->getDirectory('contacts');
          /** @var FlexObjectInterface */
          $object = $dir->createObject(
            [
              'first_name' => $form->data['first_name'],
              'last_name' => $form->data['last_name'],
              'email' => $form->data['email'],
            ],
          );
          $object->save();
        }
      }
      
  • Create a page with the following form:
    form:
      name: contacts
      fields:
        first_name:
          type: text
        last_name:
          type: text
        email:
          type: email
      buttons:
        submit:
          type: submit
      process:
        addContact:
    
  • Browse to the new page, enter some data and save the form.
  • Refresh the Contacts listing in Admin. The form’s data should be listed.

Note:

  • Off course, you will have to create your own Subscribers flex definitions using smart copy/paste of Contact definitions.