> For the complete documentation index, see [llms.txt](https://alaniso-de.gitbook.io/alaf-framework/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alaniso-de.gitbook.io/alaf-framework/untitled/untitled/checkboxes-input-feld.md).

# checkboxes input-Feld

```php
	/**
	 * Create a collection of Bootstrap checkboxes.
	 *
	 * @param string $name
	 * @param string $label
	 * @param array $choices
	 * @param array $checkedValues
	 * @param bool $inline
	 * @param array $options
	 * @return string
	 */
	public function checkboxes($name, $label = null, $choices = [], $checkedValues = [], $inline = false, array $options = []) {

```

### Parameter für das "checkbox" Input-Feld

| Name           | Titel    | Beschreibung                                                                                                                                                                                                                                                                                                |
| -------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $name          |          | Name des Input-Feldes. Dieser wird beim senden des Formulars in `$_GET` übergeben.                                                                                                                                                                                                                          |
| $label         | optional | <p>Feldüberschrift für das Eingabefeld. </p><p>Wird kein <code>$label</code> übergeben, so wird <code>$name</code> als Label übernommen.</p>                                                                                                                                                                |
| $choices       |          | array mit Key=>Value Objekten, welche zur Auswahl stehen                                                                                                                                                                                                                                                    |
| $checkedValues |          | array mit Key-Einträgen, zur "Vorbelegung" der Werte                                                                                                                                                                                                                                                        |
| $inline        | optional | **`true \| false`** bootstrap (V4 und höher) Option, zur Darstellung der Werte in horizontaler Ausrichtung                                                                                                                                                                                                  |
| $options       | optional | <p>Array mit Optionen zu einem input-Feld. Hier sind grundsätzlich alle HTML-Attribute erlaubt.</p><p>Weiterhin können interne Optionen eingetragen werden, welche die Darstellung des Input-Feldes beeinflussen. </p><p><a href="/pages/-La_ZqCaTGcWGL4-MvjG">Optionale Parameter für input-Felder</a></p> |

### Optionale Parameter für das checkboxes Input-Feld

| Name             | Titel    | Beschreibung                                                                                                                                                                                           |
| ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| value\_options   |          | <p>HTML-Attribut auf die Werte in $choices.<br>Kann genutzt werden, um z.B. ein <code>class</code>-Attribut zu setzen, welches als <code>selector</code> für javaScript / jQuery Funktionen dient.</p> |
| cbgroup\_options | optional | <p>optionen, welche auf das gruppen \<div> angewendet werden sollen<br>Siehe Beispiel Option Required.</p>                                                                                             |

### awesome-bootstrap-checkbox

Ab Version 2.x kann die formular-engine auch aufgehübschte Check- und Radio-Boxen darstellen, indem die CSS-Erweiterung awesome-bootstrap-checkbox implementiert wurde. <http://flatlogic.github.io/awesome-bootstrap-checkbox/demo/1.0.0/>

#### Beispiel

```php
// eMail-Benachrichtigung
$FormHtml [] = $tb->checkboxes ( 'config[comments_email_notifications][]', af_tran ( 'eMail versenden, wenn' ), [ 
		'new_comment' => af_tran ( 'jemand einen Kommentar schreibt' ),
		'to_approve' => af_tran ( 'ein Kommentar auf Freischaltung wartet' )
], $this->_config ['comments_email_notifications'], false, [ 
		'abc' => 'abc-checkbox-primary'
] );
			
// eMail-Benachrichtigung
$FormHtml [] = $tb->checkboxes ( 'config[comments_email_receiver][]', af_tran ( 'eMail versenden an' ), [ 
		'author' => af_tran ( 'Author' ),
		'admin' => af_tran ( 'Administrator' ),
		'sender' => af_tran ( 'Verfasser des Kommentars' )
], $this->_config ['comments_email_receiver'], false, [ 
		'abc' => [ 
				'abc-checkbox-primary',
				'abc-checkbox-success abc-checkbox-circle',
				'abc-checkbox-warning'
		]
] );
```

![](/files/-Li99HDzWAzwYE-2TzGl)

Je Wert kann eine eigene Klasse gesetzt werden. Falls nur ein Eintrag existiert, wird das Format auf alle Einträge angewendet.

### CheckBox-Group: Option Required

In manchen Fällen kann es notwendig sein, dass beim Vorkommen mehrerer Checkboxes mindestens eine ausgewählt sein muss. Dies kann mit der Check-Box-Group = "required" erreicht werden:

Zur Prüfung wird ein jQuery-Skript ausgeführt

#### Beispiel

{% tabs %}
{% tab title="PHP" %}

```php
		// eMail-Benachrichtigung
		$FormHtml [] = $FrmObj->checkboxes ( 'clarification_to[]', af_tran ( 'An welche Abteilung soll die Rückfrage adressiert werden:' ), [ 
				'AWETA' => af_tran ( 'AWETA' ),
				'MS' => af_tran ( 'Market Support' )
		], 2, false, [ 
				'abc' => [ 
						'abc-checkbox-primary',
						'abc-checkbox-primary'
				],
				'cbgroup_options' => [ 
						'class' => 'checkbox-group required'
				],
				'id' => 'btn_send_clarification_id'
		] );
		$FormHtml [] = '<div class="alert alert-danger mb-2" id="cb_send_clarivication_info_id" hidden="hidden">Bitte mindestens eine Abteilung auswählen!<br></div>';

		$FormHtml [] = $FrmObj->button ( 'frm_save', af_tran ( 'Rückfrage zustellen' ), 'user/save_Encrease', 'submit', array (
				'class' => 'btn btn-secondary ',
				'iconclass' => 'fas fa-arrow-up',
				'id' => 'btn_send_clarification_id',
				'title' => af_tran ( 'Betriebsauftrag erhöhen' )
		) );

		// JavaScript, um Eingabefeld ein/auszublenden...
		$js_script = '<script>' . "\n";
		$js_script .= "\$('#btn_send_clarification_id').on(\"click\", function (e) {" . "\n";
		$js_script .= "	if( !\$('div.checkbox-group.required :checkbox:checked').length > 0) {" . "\n";
		$js_script .= "		e.preventDefault();" . "\n";
		$js_script .= "		\$(\"#cb_send_clarivication_info_id\").removeAttr(\"hidden\");" . "\n";
		$js_script .= "	}";
		$js_script .= "});";
		$js_script .= '</script>' . "\n";

		$FormHtml [] = $js_script;

```

{% endtab %}
{% endtabs %}

![](/files/-MY3u3xoRQ31wS4EB2W8)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://alaniso-de.gitbook.io/alaf-framework/untitled/untitled/checkboxes-input-feld.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
