#BOUTON_ACTION

The #BUTTON_ACTION{label, url, class, confirm_message} tag produces the full html source for a form (POST method) with only a submit button.

  • New in : SPIP 2.1

This tag is interesting because it allows you to pass arguments to a URL using a pseudo-link which can not be followed by a robot (robots do not actually "click" on a submit button).
This is particularly useful for a URL which returns to a script that operates on the database data. Such links must therefore be protected so that it is not executed by a robot.
#BOUTON_ACTION is here to help us with that.

The tag is therefore used as follows:

#BOUTON_ACTION{libellé, url, class ,message de confirmation}

The 1st argument indicates the button label.

The 2nd argument, url, can be provided by the #URL_ACTION_AUTEUR tag.

The 3rd argument, optional, is a css class name or a sequence of CSS classes, which apply to the button; giving it the value "ajax" allows the button to behave like an ajax link; with the "noscroll" class in addition, the ajax call is made without the browser scrolling at the beginning of the page.

Since SPIP 4.0, if this argument contains ’ajax’, the form containing the button is assigned the ’ajax’ class. If necessary, you can use the |ajouter_class filter to assign other classes to it.

The optional 4th argument is used to specify the confirmation message displayed when the button is clicked on.

-  Attention:

  • if you want to specify a confirmation message, then you must also provide the 3rd argument: #BOUTON_ACTION{libellé, url ,message de confirmation} will not function as you expect it to: ("confirmation message" will simply be passed as the CSS class name). To specify a confirmation message without providing the CSS class name, write this instead:
    #BOUTON_ACTION{label, url , '',confirmation message}
    
  • If you use accented characters in your confirmation message, you must translate them into numerical entities:(é => é).

Example:

#BOUTON_ACTION{validate, #URL_PAGE{my_script}|parametre_url{var1, val1}|parametre_url{var2, val2}|parametre_url{var3, val3}, ajax, are you short?}

will generate the following HTML code:

<form class='bouton_action_post ajax' method='post' action='./?page=my_script&amp;var1=val1&amp;var2=val2&amp;var3=val3'>
<div>
<input name="page" value="mon_script" type="hidden" />
<input name="var1" value="val1" type="hidden" />
<input name="var2" value="val2" type="hidden" />
<input name="var3" value="val3" type="hidden" />
<button type='submit' class='submit' onclick='return confirm("are you short?");'>validate</button>
</div>
</form>

Author jack, Mark Published : Updated : 31/03/23

Translations : català, English, français, Nederlands