# select Feld

```php
	/**
	 * Create a select box field.
	 *
	 * @param string $name        	
	 * @param string $label        	
	 * @param array $list        	
	 * @param string $selected        	
	 * @param array $options
	 *        	[
	 *        	'placeholder' => '
	 *        	]
	 *        	
	 * @return string
	 */
	public function select($name, $label = null, $list = [], $selected = null, array $options = []) {
	// ...
	}

```

### Parameter für das select Feld

| Name      |          | Beschreibung                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $name     |          | Name des Input-Feldes. Dieser wird beim Senden des Formulars in `$_GET` übergeben.                                                                                                                                                                                                                                                                                                                                           |
| $label    | optional | Feldüberschrift für das Eingabefeld. Wird kein `$label` übergeben, so wird `$name` als Label übernommen.                                                                                                                                                                                                                                                                                                                     |
| $list     | optional | Array mit den auswählbaren Einträgen. Falls die Einträge gruppiert werden sollen, ist ein mehrdimensionales Array zu verwenden.                                                                                                                                                                                                                                                                                              |
| $selected | optional | Wert des Input-Feldes. Der übergebene Wert wird in der DropDown-Liste ausgewählt und kann bearbeitet werden.                                                                                                                                                                                                                                                                                                                 |
| $options  | optional | <p>Array mit Optionen / Attributen zu einem input-Feld. Hier sind grundsätzlich alle HTML-Attribute erlaubt. </p><p><code>'form-group' => 'no-form-group'</code> : gibt das Select ohne form-group (Label + Feld) aus.<br>Weiterhin können interne Optionen eingetragen werden, welche die Darstellung des Input-Feldes beeinflussen. <br><a href="/pages/-La_ZqCaTGcWGL4-MvjG">Optionale Parameter für input-Felder</a></p> |

### Selectpicker

Der Formulareditor ist mit der Erweiterung "bootstrap-select" ausgestattet.&#x20;

Weiter Informationen gibt es hier: <https://developer.snapappointments.com/bootstrap-select/>

Die Vollständige Dokumentation ist auf der zugehörigen Hompage einzusehen: <https://developer.snapappointments.com/bootstrap-select/options/#bootstrap-version>

### duallistbox

Der Formulareditor ist mit der Erweiterung "bootstrap-duallistbox" ausgestattet.

Weitere Informationen gibt es hier: <https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox>

Eine Dokumentation mit Beispielen gibt es hier: <https://www.virtuosoft.eu/code/bootstrap-duallistbox/>

## Beispiele

### Standard

```php
$FormHtml [] = $FrmObj->select ( 'Auswahl-Select', 'Ausahl', array (
		'1' => 'Eins',
		'2' => 'zwei' 
), '2' );

```

![Standard DropDown-Liste](/files/-Lg2YL7_x7rlfj0uOTHL)

### Group-Select

```php
FormHtml [] = $FrmObj->select ( 'Group-Select', 'Group-Auswahl', array (
		'Eins' => [ 
				'1.0' => 'Eins.Null',
				'1.1' => 'Eins.Eins' 
		],
		'Zwo' => [ 
				'2.0' => 'Zwo.Null',
				'2.1' => 'Zwo.Eins' 
		],
		'3' => 'Direkt Drei' 
), '1.0' );

```

![](/files/-Lg2Ymto8GQhfpoUwbVE)

### Bootstrap-selectpicker

```php
$choices = [ 
		'1' => 'Eins',
		'2' => 'zwei',
		'3' => 'drei',
		'4' => 'vier',
		'5' => 'fünf',
		'6' => 'SECHS' 
];

$FormHtml [] = $FrmObj->select ( 'Selectpicker[]', 'bootstrap-selectpicker', $choices, '4', [ 
		'placeholder' => af_tran ( 'ohne' ),
		'title' => 'Titel des selectpicker',
		'id' => 'alaf_selopt_id_3',
		'helptext' => 'siehe https://silviomoreto.github.io/bootstrap-select/',
		'multiple' => 'multiple',
		'selectpicker' => [ 
				'data-size' => '15',
				'data-live-search' => 'true' 
		] 
] );

```

![](/files/-Lg2e7lDeTz_2sq_mP1V)

### Bootstrap-selectpicker mit subtext

```php
$choices = [ 
		'1' => 'Eins',
		'2' => 'zwei',
		'3' => 'drei',
		'4' => 'vier',
		'5' => 'fünf',
		'6' => 'SECHS' 
];
$opt_data = [ 
		'1' => [ 
				'data-subtext' => 'hier bei Hallo' 
		],
		'2' => [ 
				'data-subtext' => 'hier bei zwo oder soo' 
		],
		'3' => [ ],
		'4' => [ 
				'data-subtext' => 'vier ist eine schöne Zahl!' 
		],
		'5' => [ 
				'data-subtext' => 'füüüüünfffff' 
		],
		'6' => [ ] 
];

$FormHtml [] = $FrmObj->select ( 'Selectpicker2[]', 'bootstrap-selectpicker', $choices, '4', [ 
		'option_data' => $opt_data, // Hier wird der Zusatztext erzeugt
		'placeholder' => af_tran ( 'ohne' ),
		'title' => 'Titel des selectpicker',
		'id' => 'alaf_selopt_id_3',
		'helptext' => 'mit Zusatztext über "option_data"-Attribut...',
		'selectpicker' => [ 
				'data-size' => '15',
				'data-show-subtext' => 'true' 
		] 
] );

```

![](/files/-Lg2ePlUpfyHXUTJctxz)

### Bootstrap-selectpicker AJAX

```php
		if ($data ['LIFNR'] == "NEW") {
			include_once (ALAF_MODULES_DIR . DS . 'Lager000\includes\class.LagerPublicFunctions.php');
			$ObjLPFOpt = new LagerPublicFunctions ();
			$choices = $ObjLPFOpt->getLfa1Opt ( [ 
					'LIFNR[=]' => $data ['LIFNR'] 
			] );
			
			$FormHtml [] = $FrmObj->select ( 'MX_LIFNR[' . $lifnr . ']', af_tran ( 'Lieferant' ), $choices, $data ['LIFNR'], [
					'placeholder' => af_tran ( 'ohne' ),
					'title' => af_tran ( 'Lieferant' ),
					'id' => 'alaf_selopt_sap_lfa1_id',
					// 'helptext' => 'wie oben, mit Ergänzung ajax! https://github.com/truckingsim/Ajax-Bootstrap-Select',
					// 'multiple' => 'multiple',
					'selectpicker' => [ 
							'data-size' => '15',
							'data-live-search' => 'true',
							'data-actions-box' => 'true',
							'data-selected-text-format' => 'count > 5',
							'data-show-subtext' => 'true',
							'data-size' => 10,
							'with-ajax' => [ 
									'ajax-url' => 'modules/Lager000/api/alaf_server_side.php',
									'ajax-type' => 'POST',
									'ajax-dataType' => 'json',
									'ajax-op' => 'get_lfa1',
									'locale-emptyTitle' => af_tran ( 'Bitte einen Eintrag wählen...' ),
									'locale-statusSearching' => af_tran ( 'Suche...' ),
									'locale-statusTooShort' => af_tran ( 'Mindestens x-Zeichen eingeben...' ),
									'locale-emptyTitle' => af_tran ( 'Select and begin typing...' ),
									'locale-errorText' => af_tran ( 'hier gab es einen Fehler!!!' ),
									'log' => 0,
									'min-length' => '2',
									'cache' => 'false',
									'clear-on-error' => 'true',
									'clear-on-empty' => 'true' 
							] 
					],
					'right_column_class' => $FrmObj->column_class [8] 
			] );
		} else {
			$FormHtml [] = $FrmObj->hidden ( 'MX_LIFNR[' . $lifnr . ']', $data ['LIFNR'] );
		}

```

Serverseitig muss ein php-skript die Datenaufbereitung vornehmen. Hier ist ein Beispiel für die Lieferantendaten....:

{% content-ref url="/pages/-Lg2h67US9vfCCB-hBAS" %}
[alaf\_server\_side.php](/alaf-framework/beispiele/alaf_server_side.php.md)
{% endcontent-ref %}

![Nach Eingabe des Suchstrings werden nur Lieferanten mit dem Suchstring angezeigt...](/files/-Lg2fs2O0aXVXyH1TauX)

### Bootstrap-duallistbox

```php
$FormHtml [] = $FrmObj->select ( 'wf_roll_ids[OWNER][]', af_tran ( 'Verantwortlich' ), $user_choices, $data ['wf_roll_ids'] ['OWNER'], [ 
		'multiple' => 'multiple',
		'element-div' => [ 
				'type' => 'card',
				'style' => 'width: 100%',
				'class' => 'bg-light'
		],
		'duallistbox' => [ 
				'moveOnSelect' => 'false',
				'selectedListLabel' => af_tran ( 'Ausgewählte Rollenverantwortliche' ),
				'nonSelectedListLabel' => af_tran ( 'Auswählbare Benutzer' ),
				'showFilterInputs' => 'true',
				'nonSelectedFilter' => '', // z.B.: 'ion ([7-9]|[1][0-2])'
				'selectedFilter' => '',
				'selectorMinimalHeight' => 100,
				'filterOnValues' => 'false' // set this to true to filter the options according to their values and not their HTML contents.
		],
		'title' => af_tran ( 'Benutzer, welche(r) für die Workflowaufgaben verantwortlich ist' ),
		'id' => 'alaf_selopt_wf_roll_owner_ids_id'
] );

```

<figure><img src="/files/9EV0Sm453sAI1SKH2OUk" alt=""><figcaption><p>Beispiel der "bootstrap-duallistbox"</p></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://alaniso-de.gitbook.io/alaf-framework/untitled/untitled-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
