Executing the processes

Whenever the verification function doesn’t return an error, the form then moves on to the traiter() (processing) function. It is in this function that the desired operations should be performed with the data from the form (send an email, update the database, etc.).

The function must return an associative table:

  1. function formulaires_nom_traiter(){
  2. // Execute the processes
  3.  
  4. // Return values
  5. return array(
  6. 'message_ok' => 'Excellent !', // or perhaps
  7. 'message_erreur' => 'Sorry, an error has occurred.'
  8. );
  9. }

Download

Important values

Here are some of the values frequently returned:

  • message_ok is used to return a pleasant message to the user indicating that everything processed normally.
  • message_erreur, on the other hand, is used to return an error message when the processing didn’t work correctly.
  • editable, as for loading, this is used to display or hide the editable portion of the form. By default it is set to false, but you may assign it a value of true if your form can be used several times in a row.
  • redirect is a URL which is used to tell SPIP which page it should redirect to after processing the form. By default, the page will loop back to itself.

The formulaire_traiter (form_process) pipeline

Once the formulaires_nom_traiter function has completed, the formulaire_traiter pipeline is executed, thereby enabling other plugins to complete the processes for this form.

Author Mark Baber Published : Updated : 02/06/10

Translations : English, français