FlexForm can be extended by a PHP function to handle additional tasks after a Form has been submitted.

Start a FlexForm and tell it to use your extension :

<_form action="addToWiki" extension="<name of you extension" >
   Your flexform elements here
</_form>

Create a folder in FlexForm/src/Modules/Handlers with the name of your extension.

In this folder create a file called PostHandler.php with the following namespace :

namespace FlexForm\Modules\Handlers\< your extension name = same as folder name >;

Your extension will be base on the HandlerInterface interface and will only hold one method : execute

The array $flexFormFields will be available and hold all submitted Form elements as name->value.

If your extension produces an error, throw a FlexFormException and FlexForm will take care of the rest. Make sure to throw a message that with your extension name.

If your extension has successfully finished its tasks, tell the responsehandler it has been successfull and return the responseHandler :

$responseHandler->setReturnType( HandleResponse::TYPE_SUCCESS );
return $responseHandler;

If your extension has successfully finished its tasks and you want to pass additional information to the user :

$responseHandler->setReturnType( HandleResponse::TYPE_SUCCESS );
$responseHandler->setReturnData( string < your message > );
return $responseHandler;

ws-page-props