generate_input_element()
function generate_input_element(string $type, string $name, ?string $value = null, bool|string|null $checked = false, array $attributes = []): string
Description
Generates a raw HTML input element with full control over type, name, value, checked state, and additional attributes. This is the underlying function used by other form helpers and provides the most flexibility for custom input field generation.
Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
| $type | string | The type attribute for the input element (e.g., 'text', 'email', 'checkbox'). | N/A |
| $name | string | The name attribute for the input element. | N/A |
| $value | ?string | The value attribute for the input element. | null |
| $checked | bool|string|null | Whether the input element should be checked (for radio/checkbox types). Accepts true, false, 'checked', or null. | false |
| $attributes | array | An associative array of additional HTML attributes. | [] |
Return Value
| Type | Description |
|---|---|
| string | The generated HTML input element as a string. |