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
Use Inspect Element to view the generated HTML code

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 the name attribute
  • Input::type - Sets the type attribute
  • Input::id - Sets the id attribute
  • Input::class - Sets the class attribute
  • Input::attr - Sets additional custom attributes
  • Input::label - Sets the control <label> content
  • Input::placeholder - Sets the placeholder attribute
  • Input::help - Sets the help text below the control
  • Input::append - Sets the appended content

Styling

To learn more about styling the <input>, see Basic Inputs demo.

Print

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.