https://github.com/itstructure/yii2-field-widgets
The form field widgets for Yii2 Framework with multilanguage mode support
https://github.com/itstructure/yii2-field-widgets
field multilanguage widget yii2
Last synced: about 1 year ago
JSON representation
The form field widgets for Yii2 Framework with multilanguage mode support
- Host: GitHub
- URL: https://github.com/itstructure/yii2-field-widgets
- Owner: itstructure
- License: mit
- Created: 2018-02-04T11:22:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-29T04:19:25.000Z (about 3 years ago)
- Last Synced: 2024-08-09T02:24:34.177Z (over 1 year ago)
- Topics: field, multilanguage, widget, yii2
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
Yii2 Field widgets
==============
## Introduction
[](https://packagist.org/packages/itstructure/yii2-field-widgets)
[](https://packagist.org/packages/itstructure/yii2-field-widgets)
[](https://packagist.org/packages/itstructure/yii2-field-widgets)
[](https://packagist.org/packages/itstructure/yii2-field-widgets)
[](https://scrutinizer-ci.com/g/itstructure/yii2-field-widgets/build-status/master)
[](https://scrutinizer-ci.com/g/itstructure/yii2-field-widgets/?branch=master)
This is form field's widgets for the yii2 framework with the next field types:
- text
- textarea
- ckeditor
- ckeditorAdmin
- file
- checkbox
- dropdown
- password
## Dependencies
- php >= 7.1
- composer
## Installation
### Base install
Via composer:
`composer require "itstructure/yii2-field-widgets": "~1.2.4"`
or in section **require** of composer.json file set the following:
```json
"require": {
"itstructure/yii2-field-widgets": "~1.2.4"
}
```
and command `composer install`, if you install yii2 project extensions first,
or command `composer update`, if all yii2 project extensions are already installed.
### If you are testing this package from local server directory
In application `composer.json` file set the repository, like in example:
```json
"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`
## Usage
### Requirements
That widgets are designed to work in form with an active **model**, which is inherited from
yii\db\ActiveRecord.
### Single mode
To use this mode, don't set `languageModel`. That will be **null**.
### 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:
```php
$form = ActiveForm::begin();
```
```php
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()
]) ?>
```
```php
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
```
```php
ActiveForm::end();
```
## License
Copyright © 2018-2023 Andrey Girnik girnikandrey@gmail.com.
Licensed under the [MIT license](http://opensource.org/licenses/MIT). See LICENSE.txt for details.