[ar] [ast] [bg] [br] [ca] [co] [cpf] [cs] [da] [de] [en] [eo] [es] [eu] [fa] [fon] [fr] [gl] [id] [it] [ja] [lb] [nl] [oc] [pl] [pt] [ro] [ru] [sk] [sv] [tr] [uk] [vi] [zh] Espace de traduction



August 2010

All the versions of this article:

The #BOUTON_ACTION{label, url, class, confirm_message} tag generates the complete HTML source for a form (POST method) that contains just a single submit type button in it.

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 (since SPIP 2.1) is here to help us with that.

The tag is therefore used as follows:

#BOUTON_ACTION{label, url, class ,confirmation message}

The option 3rd argument is a CSS class name; assigning it the value "ajax" allows the button to behave like an ajax link;
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{label, url ,confirmation message} 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:(é => é).

#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'>
<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>

Show the template of this page Site powered by SPIP | Translation area | Private area