PHP code example of marcel-maqsood / mezzio-middleware-formhandler

1. Go to this page and download the library: Download marcel-maqsood/mezzio-middleware-formhandler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

marcel-maqsood / mezzio-middleware-formhandler example snippets


    $app->route(
        '/formhandler[/]',
        [
            MazeDEV\FormularHandlerMiddleware\FormularHandlerMiddleware::class,
            App\Handler\YourHandler::class
        ],
        ['POST'],
        'formHandler'
    );
   

  'adapters' => [
      'phpmail' => [
          'reply-to' => [
              'status' => true,
              'field'  => 'mail',
          ],
              'recipients' => ['[email protected]'],
              'subject'    => 'subject',
              'sender'     => '[email protected]',
              'senderName' => 'Form', 
              'template'   => 'app::test',
      ],
  ],
    

  'adapters' => [
      'smtpmail' => [
          //same as on phpmail but           'config' => [
                  'service'    => 'smtp.googlemail.com',
                  'port'       => '465',
                  'encryption' => 'ssl',
                  'email'      => '[email protected]',
                  'password'   => 'examplepw',
              ],
          ],
      ],
  ],
    

    'adapters' => null,
    

    'forms' => [
      'contact' => [
            'fields' => [
                ...
            ],
            'adapters' => [
                null
            ],
        ],
    ],

'mazeform' => [
    'adapters' => [
        'globalTestAdapter-1' => [
            [   
                'method'         => 'smtpmail',
                'recipients'     => ['[email protected]'],
                'subject'        => 'base subject all forms that uses this specific adaper has',
                'sender'         => '[email protected]',
                'senderName'     => 'form',
                'template'       => 'app::test',
                'email_transfer' => [
                    'config' => [
                         'service'    => 'smtp.googlemail.com',
                         'port'       => '465',
                         'encryption' => 'ssl',
                         'email'      => '[email protected]',
                         'password'   => 'examplepw',
                    ],
                ],
            ],
        ],
    ],
],

'forms' => [
    'contact' => [
        'fields' => [
            ...
        ],
        'adapters' => [
            'globalTestAdapter-1',
            'secondAdapter',
            null
        ],
    ],
],
 'recipients'

'reply-to' => [
    'status' => true,
    'field' => 'mail'
],

'forms' => [
    'contact' => [
        'fields' => [
            'someFieldName' => [
                'type' => 'email',
            ],
        ],
        'adapters' => [
            ...
        ],
    ],
],

'contactForm' => [
    'fields' => [
        'somename' => [
            '

if($request->getAttribute('csrfError') != null)
{
    //your error handling goes here...
}

'contactForm' => [
    'fields' => [
        'contact' => [
            'type' => 'array',
            'childs' => [
                'salutation' => [
                    '      ],
                'surname' => [
                    'quired' => true,
                    'type' => 'int'
                ],
            ]
            //in this case, there is no
        ],
    ],
    'adapters' => [
            ...
    ],
],


'

'mazeform' => [
    'adapters' => [
        'globalExampleAdapter-1' => [
            [
                'method'         => 'smtpmail',
                'recipients'     => ['[email protected]'],
                'subject'        => 'base subject all forms that uses this specific adaper has',
                'sender'         => '[email protected]',
                'senderName'     => 'Kontaktformular',
                'template'       => 'app::test',
                'email_transfer' => [
                    'config' => [
                        'service'    => 'smtp.example.com',
                        'port'       => '465',
                        'encryption' => 'ssl',
                        'email'      => '[email protected]',
                        'password'   => 'yourPassword',
                    ],
                ],
            ],
        ],
    ],
    'forms' => [
        'contact' => [
            'fields' => [
                'name' => [
                    '               ],
                'street' => [
                ],
                'city' => [
                ],
                'country' => [
                    'subject'        => 'base subject all forms that uses this specific adaper has',
                    'sender'         => '[email protected]',
                    'senderName'     => 'Kontaktformular',
                    'template'       => 'app::test',
                    'email_transfer' => [
                        'config' => [
                            'service'    => 'smtp.example.com',
                            'port'       => '465',
                            'encryption' => 'ssl',
                            'email'      => '[email protected]',
                            'password'   => 'yourPassword',
                        ],
                    ],
                ],
            ],
        ],
    ],
],

    $app->route(
        '/formhandler[/]',
        [
            MazeDEV\FormularHandlerMiddleware\FormularHandlerMiddleware::class,
        ],
        ['POST'],
        'formHandler'
    );
   
/config/form-config.local.php
 'type' => 'array'