2017 © Pedro Peláez
 

yii2-extension yii2-form-fields

Collection of form fields

image

fgh151/yii2-form-fields

Collection of form fields

  • Wednesday, November 23, 2016
  • by fgh151
  • Repository
  • 1 Watchers
  • 0 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 10 % Grown

The README.md

Yii2 form fields

Collection of form fields, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist fgh151/yii2-form-fields "*"

or add, (*4)

"fgh151/yii2-form-fields": "*"

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, simply use it in your code by :, (*6)

$form = ActiveForm::begin();
echo \fgh151\fields\InputWidget::widget([
    'model' => $model,
    'attribute' => 'attributeName',
    'type' => \fgh151\fields\FieldTypes::getByName('text'), //default text
]);
ActiveForm::end();

Input without model, (*7)

echo \fgh151\fields\InputWidget::widget([
    'model' => new \yii\base\DynamicModel(['attributeName']),
    'attribute' => 'attributeName',
]);

Input with custom label and value, (*8)

echo \fgh151\fields\InputWidget::widget([
    'model' => new \yii\base\DynamicModel(['attributeName']),
    'attribute' => 'attributeName',
    'options' => [
                'label' => 'Custom label',
                'value' => 'Some value',
    ]
]);

Available field types: * text - input type text * email - input type email * number - input type number * textarea - text area * binaryCheckbox - single check box (for example agree field) * checkboxList - list check boxes with same name * checkboxListOther - list check boxes with same name and input text field * binaryRadio - single radio button * radioList - list of radio buttons * radioListOther - list of radio boxes with other text field * file - file input field, (*9)

BinaryCheckbox - is binary field, for example agree field, (*10)

Field type examples

checkboxList, checkboxListOther, radioList, radioListOther
echo \fgh151\fields\InputWidget::widget([
    'model' => new \yii\base\DynamicModel(['FirstName']),
    'attribute' => 'FirstName',
    'type' => 6, //You can specify direct see \fgh151\fields\FieldTypes
    'options' => [
        'variants' => [
            ['label' => 'var1', 'value' => 'var1'],
            ['label' => 'var2', 'value' => 'var2'],
            ['label' => 'var3', 'value' => 'var3'],
        ]
    ]
]);

for 'other' label you can pass custom text:, (*11)

echo \fgh151\fields\InputWidget::widget([
    'model' => new \yii\base\DynamicModel(['FirstName']),
    'attribute' => 'FirstName',
    'type' => 6, //You can specify direct see \fgh151\fields\FieldTypes
    'options' => [
        'variants' => [
            ['label' => 'var1', 'value' => 'var1'],
            ['label' => 'var2', 'value' => 'var2'],
            ['label' => 'var3', 'value' => 'var3'],
        ]
    ],
    'otherText' => 'Другое'
]);

The Versions

23/11 2016

dev-master

9999999-dev

Collection of form fields

  Sources   Download

MIT

The Requires

 

extension yii2 form fields

23/11 2016

0.0.1

0.0.1.0

Collection of form fields

  Sources   Download

MIT

The Requires

 

extension yii2 form fields