add_file_input

This commit is contained in:
SoHardKI
2019-07-26 15:31:39 +03:00
parent 9560efc7bc
commit ea96cfe152
6 changed files with 402 additions and 12 deletions

View File

@ -3,6 +3,7 @@
namespace backend\modules\card\models;
use backend\modules\settings\models\Skill;
use common\classes\Debug;
use common\models\CardSkill;
use common\models\FieldsValue;
use common\models\FieldsValueNew;
@ -61,11 +62,14 @@ class UserCard extends \common\models\UserCard
if($post['fields']){
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_PROFILE]);
foreach ( $post['fields'] as $item) {
$fildsValue = new FieldsValueNew();
$fildsValue->field_id = $item['field_id'];
$fildsValue->value = $item['value'];
$fildsValue->type_file = 'text';
if(substr($item['value'],0,1) == '/'){
$fildsValue->type_file = 'file';
}
$fildsValue->order = $item['order'];
$fildsValue->item_id = $this->id;
$fildsValue->item_type = FieldsValueNew::TYPE_PROFILE;

View File

@ -145,12 +145,21 @@ use yii\widgets\ActiveForm;
'options' => ['prompt' => 'Выберите']
],
[
'name' => 'value',
'name' => 'value',
'title' => 'Значение',
'enableError' => true,
'type' => InputFile::className(),
'options' => [
'class' => 'input-priority'
]
'language' => 'ru',
'controller' => 'elfinder',
// вставляем название контроллера, по умолчанию равен elfinder
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
'name' => 'fields[value]',
'id' => 'fields-value',
'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
'buttonOptions' => ['class' => 'btn btn-primary'],
'value' => $model->fields[0]['value'],
'buttonName' => 'Выбрать файл',
],
],
[
'name' => 'order',
@ -161,10 +170,6 @@ use yii\widgets\ActiveForm;
]
],
],
// 'extraButtons' => function ($model, $index, $context) {
// Html::addCssClass($options, 'btn multiple-input-list__btn js-input-plus btn btn-default');
// return Html::tag('div', Html::a('', ['index'], ['class' => 'glyphicon glyphicon-plus plus-icon']), $options);
// },
])->label('Дополнительно');
?>
</div>