Skip to content

Commit

Permalink
Correction: re-introduced missing form_input() function
Browse files Browse the repository at this point in the history
  • Loading branch information
trongate committed Sep 23, 2023
1 parent df1cf06 commit 68ae88e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions engine/tg_helpers/form_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,33 @@ function form_label($label_text, $attributes = null, $additional_code = null) {
return '<label' . $extra . '>' . $label_text . '</label>';
}

/**
* Generate an HTML input element.
*
* @param string $name The name attribute for the input element.
* @param mixed $value (optional) The initial value for the input element. Default is null.
* @param array|null $attributes (optional) Additional attributes for the input element. Default is null.
* @param string|null $additional_code (optional) Additional code to include in the input element. Default is null.
*
* @return string The HTML representation of the input element.
*/
function form_input(string $name, $value = null, ?array $attributes = null, ?string $additional_code = null): string {
$extra = '';
if (!isset($value)) {
$value = '';
}

if (isset($attributes)) {
$extra = get_attributes_str($attributes);
}

if (isset($additional_code)) {
$extra .= ' ' . $additional_code;
}

return '<input type="text" name="' . $name . '" value="' . $value . '"' . $extra . '>';
}

/**
* Generate an HTML input element with type "number".
*
Expand Down

0 comments on commit 68ae88e

Please sign in to comment.