Class thoulah\fontawesome\bootstrap4\ActiveField

Inheritancethoulah\fontawesome\bootstrap4\ActiveField » yii\bootstrap4\ActiveField

Provides an easy way to use icons in forms are described on the Boostrap Input group page.

Automatic

use thoulah\fontawesome\bootstrap4\ActiveForm;

$form = ActiveForm::begin();

echo $form->field($model, 'field1', [
    'icon' => 'user',
]);

echo $form->field($model, 'field2', [
    'icon' => [
        'name' => 'github',
        'style' => 'brands',
    ],
]);

echo $form->field($model, 'field3', [
    'icon' => [
        'name' => 'github',
        'style' => 'brands',
        'append' => true,
    ],
]);

ActiveForm::end();

Manual

For $icon you can use thoulah\fontawesome\Icon or thoulah\fontawesome\IconComponent.

$form = ActiveForm::begin();

echo $form->field($model, 'field', [
    'inputTemplate' => $icon->activeFieldAddon('user'),
]);

ActiveForm::end();
$form = ActiveForm::begin();

echo $form->field($model, 'field', [
    'inputTemplate' => '<div id="yourClass" class="float-right">YourText</div>' .
        $icon->activeFieldAddon('font-awesome', ['style' => 'brands']),
]);

ActiveForm::end();
$form = ActiveForm::begin();

echo $form->field($model, 'field', [
    'inputTemplate' => '<div class="input-group">YourText' .
        $icon->activeFieldIcon('font-awesome', ['style' => 'brands']).'{input}</div>',
]);

ActiveForm::end();

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$icon array Per-icon settings thoulah\fontawesome\bootstrap4\ActiveField

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. thoulah\fontawesome\bootstrap4\ActiveField
render() Renders the whole field. thoulah\fontawesome\bootstrap4\ActiveField

Property Details

$icon public property

Per-icon settings

public array $icon null

Method Details

__construct() public method

Constructor.

public void __construct ( $config = [] )
$config array

Name-value pairs that will be used to initialize the object properties

render() public method

Renders the whole field.

public string render ( $content null )
$content string|callable

The content within the field container

return string

The rendering result