Ein input-field wird zur Eingabe von allgemeinen Werten im Formular verwendet.
/**
* Create the input group for an element with the correct classes for errors.
*
* @param string $type
* @param string $name
* @param string $label
* @param string $value
* @param array $options
* @return string
*/
public function input($type, $name, $label = null, $value = null, array $options = []) {
...}
$type |
HTML-Formuar Input-Type:
für spezielle Eingabetypen gibt es jeweils einen eigenen Funktionsaufruf, da die Parameterleiste unterschiedlich sein kann! |
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$name | Name des Input-Feldes. Dieser wird beim senden des Formulars in $_GET übergeben. | ||||||||||||
$label | Feldüberschrift für das Eingabefeld. Wird kein $label übergeben, so wird $name als Label übernommen | ||||||||||||
$value | Eingabewert für das Input-Feld. | ||||||||||||
$options |
Array mit Optionen zu einem input-Feld. Hier sind grundsätlich alle HTML-Attribute möglich. Weiterhin können interne Optionen eingetragen werden, welche die Darstellung des Input-Feldes beeinflussen Interne Optionen:
|
Beispiel:
Input-Feld mit einem Hilfe-Text, einer Hilfe-Text-ID und eienr Text-Klasse
$FormHtml [] = $tb->input ( 'input', 'VORNAME', af_tran('Vorname'), 'Mike', [
'helptext' => [
'Bitte geben Sie den Vornamen ein',
'class' => "text-danger",
'id' => 'helptext_id'
]
] );
Beispiel:
Input-Feld mit einer input-group, bestehend aus einem linken Führungstext und einem rechten Ergänzungstext.
$FormHtml [] = $tb->input ( 'input', 'AUSS_KG2', af_tran('Ausschuss'), '1250', [
'input-group' => [
'input-group-addon-left' => [
'text' => 'Kilo',
'class' => '',
'iconclass' => ''
],
'input-group-addon-right' => [
'text' => '.00',
'class' => ''
]
],
'helptext' => af_tran('Ausschuss in KG'),
'size' => '10',
'maxlength' => '10',
'title' => af_tran('Ausschuss in KG')
] );
Beispiel:
Mehrere Eingabefelder nebeneinander im horizontalen Formular.
/*
* Beispiel für mehrere Felder in einem horizontalen Formular:
*
* Erreicht wird dies über die Option 'form-group' => ['form-group' => 'no-form-group'] für
* jede Label|Field-Gruppe
*/
// 1. Input in eine neue "Zeilen"-Variable
// form-group muss 'no-form-group' option enthalten!
$FormRow = $tb->input ( 'input', 'MeinInputFeld2', 'Auch mit helptext', 'Inhalt', [
'helptext' => 'Hinweis zum Eingabefeld...',
'left_column_class' => $tb->getLeftColumnClass (), // Standard-Linke Spalte vom Formular!
'right_column_class' => $tb->column_class [3],
'form-group' => [
'form-group' => 'no-form-group'
]
] );
// 2. nächste Label|Spaltenkombi mit jeweiligen Spaltenbreiten in "Zeilen"-Variablen anhängen
$FormRow .= $tb->number ( 'MeinInputFeld99', 'Gewicht', '150', [
'helptext' => 'Bitte Gewicht eingeben',
'input-group' => [
'input-group-addon-left' => [
'text' => 'KG',
'class' => '',
'iconclass' => ''
],
'input-group-addon-right' => [
'text' => '.00',
'class' => ''
]
],
'left_column_class' => $tb->column_class [1],
'right_column_class' => $tb->column_class [2],
'form-group' => [
'form-group' => 'no-form-group'
]
] );
// 2b nächste Label|Spaltenkombi mit jeweiligen Spaltenbreiten in "Zeilen"-Variablen anhängen
$FormRow .= $tb->email ( 'eMail-Adresse', 'eMail:', 'ich@123.de', [
'required' => 'required',
'helptext' => 'please enter your eMail...',
'left_column_class' => $tb->column_class [1],
'right_column_class' => $tb->column_class [3],
'form-group' => [
'form-group' => 'no-form-group'
]
] );
// 3. die Zeile um die Form-Group ergänzen
$FormRow = $tb->getFormGroup ( null, $FormRow, [ ] );
// 4. die "Zeilen"-Variable an das Formular-Array übergeben:
$FormHtml [] = $FormRow;