(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
FFAfterFormHandling hook
 
FFAfterFormHandling hook
  
When FlexForm is finished processing a submit form and just before it will set notification and return to the user, this Hook will run.
+
When FlexForm
 +
 
 +
* is initiated with an extension
 +
* is finished processing a submit and just before it will set notifications and return to the user
 +
 
 +
it (FlexForm) will first search for the extension in the extension folder. If it cannot find it, the '''FFAfterFormHandling''' Hook will run.
  
 
Allowing people to do additional actions with the information submitted by the Form.
 
Allowing people to do additional actions with the information submitted by the Form.
 
{| class="wikitable"
 
{| class="wikitable"
 
|+
 
|+
 +
! colspan="2" |<center>FFAfterFormHandling</center>
 +
|-
 +
| colspan="2" |<center>Available since version 1.1.15</center>
 +
|-
 +
| colspan="2" |<center>Allows final actions on form values before output</center>
 +
|-
 +
|function
 +
|<code>public static function onFFAfterFormHandling( string $external, array $flexFormFields, HandleResponse &$responseHandler ) { ... }</code>
 +
|-
 +
|hook
 +
|<code>$wgHooks['FFAfterFormHandling'][] = 'MyExtensionHooks::onFFAfterFormHandling';</code>
 +
|-
 +
|called from
 +
|<code>FlexForm/src/Processors/Request/External.php. Method: runHook</code>
 +
|}
 +
 +
The string $external will hold the name of the extension that was assigned to the form.
 +
 +
The array <code>$flexFormFields</code> will be available and hold all submitted Form elements as '''name->value'''.
  
 
responseHandler function :
 
responseHandler function :
Line 17: Line 41:
 
<code>$responseHandler->setReturnData( "Details information" );</code>
 
<code>$responseHandler->setReturnData( "Details information" );</code>
  
on success you only have to return true. If you want to add a message that FlexForm should who, then you can do the following :
+
on success you only have to return true. If you want to add a message that FlexForm should show, then you can do the following :
  
 
<code>$responseHandler->setReturnType( HandleResponse::TYPE_SUCCESS);</code>
 
<code>$responseHandler->setReturnType( HandleResponse::TYPE_SUCCESS);</code>
Line 23: Line 47:
 
<code>$responseHandler->setReturnData( "Success information" );</code>
 
<code>$responseHandler->setReturnData( "Success information" );</code>
  
Always return true;
+
'''Always return true;'''
 
 
! colspan="2" |<center>BeforeCreateEchoEvent</center>
 
|-
 
| colspan="2" |<center>Available since version 1.1.14</center>
 
|-
 
| colspan="2" |<center>Allows final actions on form values before output</center>
 
|-
 
|function
 
|public static function onFFAfterFormHandling( $formFields, &$responseHandler ) { ... }
 
|-
 
|hook
 
|$wgHooks['FFAfterFormHandling'][] = 'MyExtensionHooks::onFFAfterFormHandling';
 
|-
 
|called from
 
|FlexForm/src/Processors/Request/External.php. Method: runHook
 
|}
 
ws-class-props
Line 1: Line 1:
 
+
{{Doc properties
 +
|Doc subject=DevOps:Doc/FlexForm
 +
|Subject version=1.1,2.0,2.1
 +
|Doc parent=
 +
|Doc sort order=260
 +
|Doc target group=Developer
 +
|Doc synopsis=FlexForm hooks MediaWiki
 +
}}
ws-page-props
Line 1: Line 1:
{{Doc properties
+
 
|Doc subject=DevOps:Doc/FlexForm
 
|Subject version=1.1
 
|Doc parent=
 
|Doc sort order=260
 
|Doc target group=Developer
 
}}
 

Latest revision as of 21:14, 31 March 2023

FFAfterFormHandling hook

When FlexForm

  • is initiated with an extension
  • is finished processing a submit and just before it will set notifications and return to the user

it (FlexForm) will first search for the extension in the extension folder. If it cannot find it, the FFAfterFormHandling Hook will run.

Allowing people to do additional actions with the information submitted by the Form.

FFAfterFormHandling
Available since version 1.1.15
Allows final actions on form values before output
function public static function onFFAfterFormHandling( string $external, array $flexFormFields, HandleResponse &$responseHandler ) { ... }
hook $wgHooks['FFAfterFormHandling'][] = 'MyExtensionHooks::onFFAfterFormHandling';
called from FlexForm/src/Processors/Request/External.php. Method: runHook

The string $external will hold the name of the extension that was assigned to the form.

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

responseHandler function :

on error :

$responseHandler->setReturnType( HandleResponse::TYPE_ERROR );

$responseHandler->setReturnStatus( "Your general error info" );

$responseHandler->setReturnData( "Details information" );

on success you only have to return true. If you want to add a message that FlexForm should show, then you can do the following :

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

$responseHandler->setReturnData( "Success information" );

Always return true;