PHP Controls Bootstrap controls for PHP
\Bootstrap\Components\Input
Code
$input = new \Bootstrap\Components\Input('email', ['required' => true]);
$input
->id('user-email')
->type('email')
->class('bg-success-50')
->label('Email')
->value('lodev09@smartadmin.lodev09.com')
->help('Use Inspect Element to view the generated HTML code');
$input->printHtml();
Result
Documentation
\Bootstrap\Components\Input
A component that enables you to easily write <input>
control through PHP.
Usage
Instantiate the Input
by passing a name
.
$input = new \Bootstrap\Components\Input('email');
$input->type('email');
// continued below...
Options
Input::options
Option | Default | Description |
---|---|---|
disabled |
false |
If the control is disabled |
grouped |
true |
If grouped by div.form-group |
group_class |
'' |
Additional div.form-gruop.* classes |
required |
false |
Add or omit required="true" attribute |
Example:
// during init
$input = new \Bootstrap\Components\Input($name, ['disabled' => true]);
// after init
$input->options('disabled', true);
Other properties
Input::name
- Sets thename
attributeInput::type
- Sets thetype
attributeInput::id
- Sets theid
attributeInput::class
- Sets theclass
attributeInput::attr
- Sets additional custom attributesInput::label
- Sets the control<label>
contentInput::placeholder
- Sets theplaceholder
attributeInput::help
- Sets the help text below the controlInput::append
- Sets the appended content
Styling
To learn more about styling the <input>
, see Basic Inputs demo.
Finally, once you configured your input, you can now htmlPrint
it!
$input->printHtml();
Credits
\Bootstrap\Components\Input
is part of the lodev09/bootstrap-php package created by @lodev09.