Input Text
get_input_text
PHP Developer Guide: get_input_text Function
This guide explains how to use the get_input_text function from your PHP framework. This function generates a styled HTML <input type="text"> or <input type="password"> field using your custom input rendering engine. And a lot of custom input elements.
It supports:
- Readonly rendering
- Custom classes, placeholders, and attributes
Manual Example with get_input_text
- JSON
- PHP
- HTML
{
"element": [{
"input_text": {
"title": "Username",
"name": "username",
"placeholder": "Enter your username"
}
}]
}
$magic->get_input_text('username', 'John Doe',
[
'title' => 'Username',
...
]);
<div class="w_40 did-floating-label-content">
<input type="text" name="username" class="did-floating-input" value="John Doe" />
<label class="did-floating-label">Username</label>
</div>
generate_input
PHP Developer Guide: generate_input Function
You can also use generate_input() method
private function generate_input($name, $value, $params, $type, $readonly, $special_folder = '')
Manual Example with generate_input
$this->generate_input(
'username',
'JohnDoe',
[
'title' => 'Username',
'add_input_class' => ['custom-class'],
'attr' => ['data-id' => '50'],
...
],
'text',
''
);
Behavior
- Type selection:
type = passwordrenders input type password, otherwise defaults to text. - Readonly: Passed as an optional flag to generate a readonly field.
- Custom attributes: Support for
placeholder,title,class,id, andattrarrays.
Usage Notes
- Use
titleto define label text (falls back to$this->app->language($name)). - Define extra classes with
add_input_class. - Use
readonlyorattr['readonly']to disable editing. - Ideal for editing forms.