formulaire_traiter

This pipeline is called in ecrire/public/aiguiller.php after the processes have been run for a CVT form. It is used to supplement the response table or to perform any additional processes.

It accepts the same arguments as the formulaire_charger or formulaire_verifier pipelines. It returns the table of data that are the results of processing (error message, success message, redirection, editable form refresh...).

$rev = pipeline(
    'formulaire_traiter',
    array(
        'args' => array('form'=>$form, 'args'=>$args),
        'data' => $rev)
);

Example

The "Licence" plugin, which offers the opportunity to assign a usage licence to articles, uses this pipeline to save the default licence value in the configuration details whenever a new article is created:

function licence_formulaire_traiter($flux){
    // if creating a new article, assign it the configured default licence
    if ($flux['args']['form'] == 'editer_article' AND $flux['args']['args'][0] == 'new') {
        $id_article = $flux['data']['id_article'];
        $licence_defaut = lire_config('licence/licence_defaut');
        sql_updateq('spip_articles', array('id_licence' => $licence_defaut), 'id_article=' . intval($id_article));
    }
    return $flux;
}

Notes:

  • the lire_config() PHP function belongs to the configuration plugin "CFG".
  • in SPIP 2.1, it will be more relevant to use the pre_insertion pipeline for this specific example.

Author Mark Baber Published : Updated : 12/05/17

Translations : English, français