itstructure/yii2-field-widgets The form field widgets for Yii2 Framework with multilanguage mode support.

widgetfieldmultilanguage

Yii2 Field widgets

1 Introduction

Latest Stable Version Latest Unstable Version License Total Downloads Build Status Scrutinizer Code Quality

This is form field's widgets for the yii2 framework with the next field types:

  • text
  • textarea
  • ckeditor
  • ckeditorAdmin
  • file
  • checkbox
  • dropdown
  • password

2 Dependencies

  • php >= 7.1
  • composer

3 Installation

3.1 Base install

Via composer:

composer require "itstructure/yii2-field-widgets": "^1.2.2"

or in section require of composer.json file set the following:

"require": {
    "itstructure/yii2-field-widgets": "^1.2.2"
}

and command composer install, if you install yii2 project extensions first,

or command composer update, if all yii2 project extensions are already installed.

3.2 If you are testing this package from local server directory

In application composer.json file set the repository, like in example:

"repositories": [
    {
        "type": "path",
        "url": "../yii2-field-widgets",
        "options": {
            "symlink": true
        }
    }
],

Here,

yii2-field-widgets - directory name, which has the same directory level like application and contains yii2 field widgets package.

Then run command:

composer require itstructure/yii2-field-widgets:dev-master --prefer-source

4 Usage

4.1 Requirements

That widgets are designed to work in form with an active model, which is inherited from yii\db\ActiveRecord.

4.2 Single mode

To use this mode, don't set languageModel. That will be null.

4.3 Multilanguage mode

All fields will be with a language postfix:

title_en

description_en

title_ru

description_ru, e t. c.

For this mode it's necessary to have Language model with some of languages records.

Example:

$form = ActiveForm::begin();
echo Fields::widget([
    'fields' => [
        [
            'name' => 'title',
            'type' => FieldType::FIELD_TYPE_TEXT,
        ],
        [
            'name' => 'description',
            'type' => FieldType::FIELD_TYPE_CKEDITOR_ADMIN,
            'preset' => 'full',
            'options' => [
                'filebrowserBrowseUrl' => '/ckfinder/ckfinder.html',
                'filebrowserImageBrowseUrl' => '/ckfinder/ckfinder.html?type=Images',
                'filebrowserUploadUrl' => '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                'filebrowserImageUploadUrl' => '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                'filebrowserWindowWidth' => '1000',
                'filebrowserWindowHeight' => '700',
            ]
        ],
    ],
    'model'         => $model,
    'form'          => $form,
    'languageModel' => new Language()
]) ?>
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
ActiveForm::end();

License

Copyright © 2018 Andrey Girnik girnikandrey@gmail.com.

Licensed under the MIT license. See LICENSE.txt for details.

Changelog

CHANGE LOG:

1.2.2 August 10, 2018:

  • Change display translates in tableMultilanguage file by tabs.

1.2.1 August 9, 2018:

  • Code fixes according with the PSR standards.

1.2.0 May 12, 2018:

  • Modify dependencies: minimum-stability is set to dev.
  • Set prefer-stable is true
  • Add .scrutinizer file.
  • Add badges:
    • Latest Stable Version
    • Latest Unstable Version
    • License
    • Total Downloads.
    • Build Status
    • Scrutinizer Code Quality

1.1.0 February 13, 2018:

  • Depricate className() function. Use WidgetClass::class.

1.0.0 February 4, 2018:

  • Create form field's widgets for the yii2 framework with the next field types:

    • text
    • textarea
    • ckeditor
    • ckeditorAdmin
    • file
    • checkbox
    • dropdown
    • password
  • Create documentation.

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.2.2 is the latest of 5 releases



MIT license
Stats
1 github stars & 0 github forks
0 downloads in the last day
2 downloads in the last 30 days
62 total downloads