# button

```php
/**
 * Create a Bootstrap form-button.
 *
 * @param unknown $name
 * @param string $label
 * @param string $value
 * @param string $type
 *        	[button|submit|reset]
 * @param array $options
 *        	[
 *        	'class' => 'btn btn-default',
 *        	'iconclass' => 'glyphicon glyphicon-floppy-saved',
 *        	'formaction' => 'modules.php?op=xyz',
 *        	'confirm' => [
 *            'tool'      => ''   // ['' | 'bootstrap-confirmation']
 *        	  'confirm_1' => af_tran ( 'Die Freigabe wird zurückgenommen!' ),
 *        	  'confirm_2' => af_tran ( 'Wollen Sie die Freigaben wirklich zurücknehmen?' )
 *        	  ]
 *        	]
 * @return string
 */
public function button($name, $label = null, $value = null, $type = 'button', array $options = []) {
	...
}

```

### Parameter für das button Objekt

| Name     |          | Beschreibung                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $name    |          | Name des Butons. Dieser wird beim Senden des Formulars in `$_GET` übergeben.                                                                                                                                                                                                                                                                                                                                                                 |
| $label   | optional | Beschriftung der Schaltfläche / des Buttons. Wird kein `$label` übergeben, so wird `$name` als Label übernommen.                                                                                                                                                                                                                                                                                                                             |
| $value   |          | Wert des button-Feldes. Dieser Wert wird beim Senden des Formulars in $name übergeben.                                                                                                                                                                                                                                                                                                                                                       |
| $type    |          | HTML-Buttontype: 'button', 'submit', ...                                                                                                                                                                                                                                                                                                                                                                                                     |
| $options | optional | <ol><li>Array mit Optionen / Attributen zu einem input-Feld. Hier sind grundsätzlich alle HTML-Attribute erlaubt. </li><li>Spezifische Optionen:<br>'confirm' <code>=> \[]</code> : Parameter für einenn "Confirm-Button".</li><li>Weiterhin können interne Optionen eingetragen werden, welche die Darstellung des Input-Feldes beeinflussen. <br><a href="../input-optionale-parameter">Optionale Parameter für input-Felder</a></li></ol> |

### Button - Confirm

Falls zur Bestätigung einer Aktion durch eine Schaltfläche eine Sicherheitsabfrage / Bestätigung erforderlich ist, so kann dies mit der Option `'confirm' => []` definiert werden!

| Option     | Wert  | Beschreibung                                                                                                                                                                                    |
| ---------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| confirm\_1 | Text  | Bestätigungstext für die erste Abfrage                                                                                                                                                          |
| confirm\_2 | Text  | <p>Bestätigungstext, falls es eine 2te Bestätigung geben soll. </p><p><em>Nicht für Bootstrap-Confirmation</em></p>                                                                             |
| tool       | Array | In dem optionalen Array kann die Darstellungsform / Tool für die Bestätigung definiert werden. Aktuell gibt es die **Browser-Confirmation** (default) und das Tool "**Bootstrap-Confirmation**" |

#### Browser-Confirmation

Bei dieser (default) Option wird die Browser-Funktion `confirm()` aufgerufen.

![Browser-Bestätigung: Das System ruft die Funktion confirm() des Browsers auf...](https://2547061836-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaV7PHur_BU6MA3-5lA%2F-Lpi3FNKuxxKd28-ZE9u%2F-Lpi5AMifBOx2xHFRYVt%2Fbutton_confirm_browser.png?alt=media\&token=29831252-cf13-4b6e-a047-8c9f93fd60b0)

```php
$FormHtml [] = $FrmObj->button ( 'frm_save', af_tran ( 'Browser-Bestätigung' ), 'user/pick_send', 'submit', array (
		'class' => 'btn btn-success',
		'iconclass' => 'fa fa-envelope fa-check-circle-o',
		'id' => 'btn_save_and_unsend_id',
		'title' => af_tran ( 'Bestätigung mit Browser-Alert' ),
		'confirm' => [
				'confirm_1' => af_tran ( 'Komissionierung wird abgeschlossen: eMail an den Besteller wird versendet!' ),
				'confirm_2' => af_tran ( 'Wollen Sie die Komissionierung abschliessen und eine eMail versenden?' )
		]
) );
```

#### Bootstrap-Confirmation

Diese Option nutzt das Plugin **Boots-Confirmation**, weitere Informationen gibt es hier:

[Git (mistic100 / Bootstrap-Confirmation)](https://github.com/mistic100/Bootstrap-Confirmation)  [Doku und Beispiele](http://bootstrap-confirmation.js.org/)

![](https://2547061836-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaV7PHur_BU6MA3-5lA%2F-Lpi3FNKuxxKd28-ZE9u%2F-Lpi7B5DOOPfEFfhJI3x%2Fbutton_bootstrap-confirmation.png?alt=media\&token=13c98110-6a62-46fe-b316-de6617d8d4b7)

```php
$FormHtml [] = $FrmObj->button ( 'frm_save', af_tran ( 'bootstrap-confirmation-Tool' ), 'user/pick_send', 'submit', array (
		'class' => 'btn btn-success',
		'iconclass' => 'fa fa-envelope fa-check-circle-o',
		'id' => 'btn_test_bootbox_id',
		'title' => af_tran ( 'Bestätigung mit (bootstrap-confirmation)' ),
		'confirm' => [
				'tool' => [
						'toolname' => 'bootstrap-confirmation',
						'btnOkLabel' => 'O.K.',
						'btnCancelLabel' => 'Abbrechen'
				],
				'confirm_1' => af_tran ( 'Die Freigabe wird zurückgenommen!' )
		]
) );
```

| Option           | Werte                    | Beschreibung                                                                                                              |
| ---------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| toolname         | 'bootstrap-confirmation' | Wählt das Plugin "**bootstrap-confirmation**" aus.                                                                        |
| btnOkLabel       | string                   | Label of the "Ok" button.                                                                                                 |
| btnOkClass       | string                   | Class of the "Ok" button.                                                                                                 |
| btnOkIconClass   | string                   | Icon-Class of the "Ok" button                                                                                             |
| btnOkIconContent | string                   | Icon content of the "Ok" button.                                                                                          |
| html             | 'true'\|'false'          | Falls die Nachricht (confirm\_1) als HTML-Text ausgegeben werden soll, muss dieser Parameter auf **true** gesetzt werden! |
| weitere          |                          | siehe [bootstrap-confirmation.js.org](http://bootstrap-confirmation.js.org/)                                              |
