'; } /** * Rendert ein Zahlenfeld mit Buttons zum verstellen * * @param string $name * @param string $label * @param int $value * @param array $data_attributes * @return string */ function form_spinner(string $name, string $label, int $value, array $data_attributes = []) { $id = 'spinner-' . $name; $attr = ''; foreach ($data_attributes as $attr_key => $attr_value) { $attr .= ' data-' . $attr_key . '="' . $attr_value . '"'; } return form_element($label, '
' . $text . '
'); } /** * Rendert den Absenden-Button eines Formulars * * @param string $name * @param string $label * @param string $class * @param bool $wrapForm * @param string $buttonType * @return string */ function form_submit($name, $label, $class = '', $wrapForm = true, $buttonType = 'primary') { $button = ''; if (!$wrapForm) { return $button; } return form_element( null, $button ); } /** * Rendert ein Formular-Textfeld * * @param string $name * @param string $label * @param string $value * @param bool $disabled * @param int|null $maxlength * @param string|null $autocomplete * @param string|null $class * @param array $data_attributes * @return string */ function form_text($name, $label, $value, $disabled = false, $maxlength = null, $autocomplete = null, $class = '', $data_attributes = []) { $disabled = $disabled ? ' disabled="disabled"' : ''; $maxlength = $maxlength ? ' maxlength=' . (int) $maxlength : ''; $autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : ''; $attr = ''; foreach ($data_attributes as $attr_key => $attr_value) { $attr .= ' data-' . $attr_key . '="' . $attr_value . '"'; } return form_element( $label, '', 'form_' . $name, $class ); } /** * Renders a text input with placeholder instead of label. * * @param string $name Input name * @param string $placeholder Placeholder * @param string $value The value * @param boolean $disabled Is the field enabled? * @return string */ function form_text_placeholder($name, $placeholder, $value, $disabled = false) { $disabled = $disabled ? ' disabled="disabled"' : ''; return form_element( '', '' ); } /** * Rendert ein Formular-Emailfeld * * @param string $name * @param string $label * @param string $value * @param bool $disabled * @param string|null $autocomplete * @param int|null $maxlength * * @return string */ function form_email($name, $label, $value, $disabled = false, $autocomplete = null, $maxlength = null) { $disabled = $disabled ? ' disabled="disabled"' : ''; $autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : ''; $maxlength = $maxlength ? ' maxlength=' . (int) $maxlength : ''; return form_element( $label, '', 'form_' . $name ); } /** * Rendert ein Formular-Dateifeld * * @param string $name * @param string $label * @return string */ function form_file($name, $label) { return form_element( $label, sprintf('', $name), 'form_' . $name ); } /** * Rendert ein Formular-Passwortfeld * * @param string $name * @param string $label * @param string $autocomplete * @param bool $disabled * @return string */ function form_password($name, $label, $autocomplete, $disabled = false) { $disabled = $disabled ? ' disabled="disabled"' : ''; return form_element( $label, sprintf( '', $name, config('min_password_length'), $autocomplete, $disabled ), 'form_' . $name ); } /** * Renders a password input with placeholder instead of label. * * @param string $name * @param string $placeholder * @param bool $disabled * @return string */ function form_password_placeholder($name, $placeholder, $disabled = false) { $disabled = $disabled ? ' disabled="disabled"' : ''; return form_element( '', '', 'form_' . $name ); } /** * Rendert ein Formular-Textfeld * * @param string $name * @param string $label * @param string $value * @param bool $disabled * @return string */ function form_textarea($name, $label, $value, $disabled = false) { $disabled = $disabled ? ' disabled="disabled"' : ''; return form_element( $label, '', 'form_' . $name ); } /** * Rendert ein Formular-Auswahlfeld * * @param string $name * @param string $label * @param string[] $values * @param string $selected * @param string $selectText * @param string $class * @return string */ function form_select($name, $label, $values, $selected, $selectText = '', $class = '') { return form_element( $label, html_select_key('form_' . $name, $name, $values, $selected, $selectText), 'form_' . $name, $class ); } /** * Rendert ein Formular-Element * * @param string $label * @param string $input * @param string $for * @param string $class * @return string */ function form_element($label, $input, $for = '', $class = '') { $class = $class ? ' ' . $class : ''; if (empty($label)) { return '