tklustig
tklustig

Reputation: 503

Yii2: Increasing FileInput width using ActiveForm of kartik

A simple question, but unfortunately no answer available:

I'm using ActiveForm of kartik like this

<?php
    $form = ActiveForm::begin([
                'id' => 'dynamic-form',
                'type' => ActiveForm::TYPE_INLINE,
                'formConfig' => [
                    'showLabels' => false,
                    'formConfig' => ['deviceSize' => ActiveForm::SIZE_LARGE]
    ]]);
?>

and widget uploading files like this

<div class="col-md-12">
        <?=
        $form->field($model, 'attachement[]', ['horizontalCssClasses' => [''deviceSize' => ActiveForm::SIZE_LARGE]])->widget(FileInput::classname(), [
            'options' => ['multiple' => true],
            'pluginOptions' => ['allowedFileExtensions' => ['jpg', 'bmp', 'png', 'docx', 'doc', 'xls', 'xlsx', 'csv', 'ppt', 'pptx', 'pdf', 'txt', 'avi', 'mpeg', 'mp3', 'sql']
            ],
        ])
        ?>
</div>

Whatever I try, bootstrap rule col-md-12 will be ruling inoperative 'cause of using TYPE-INLINE. Using TYPE-HORIZONTAL fulfills my intention, but I need TYPE-INLINE for other input fields.

Any ideas how to achieve my intention showing widget over whole screen width?

Upvotes: 0

Views: 1061

Answers (1)

Muhammad Omer Aslam
Muhammad Omer Aslam

Reputation: 23738

if you are trying to add the class col-sm-12 to the container tags of the form group elements/fields then you can use the fieldConfig option of the form like below

<?php
$form = ActiveForm::begin ( [
            'id' => 'dynamic-form' ,
            'type' => ActiveForm::TYPE_INLINE ,
            'fieldConfig' => [
                'options' => [
                    'class' => 'col-sm-12 form-group' ,
                    'tag' => 'div'
                ]
            ] ,
            'formConfig' => [
                'showLabels' => false ,
                'formConfig' => [ 'deviceSize' => ActiveForm::SIZE_LARGE ]
    ] ] );
?>

and if you want to add this class only to the container div of the file field widget then add it via options of the field

<?=
$form->field ( $modelUpload , 'file',[
    'options'=>['class'=>'form-group col-sm-12'],
] )->widget ( FileInput::classname () , [
    'options' => [ 'multiple' => true ] ,
    'pluginOptions' => [ 'allowedFileExtensions' => [ 'jpg' , 'bmp' , 'png' , 'docx' , 'doc' , 'xls' , 'xlsx' , 'csv' , 'ppt' , 'pptx' , 'pdf' , 'txt' , 'avi' , 'mpeg' , 'mp3' , 'sql' ]
    ] ,
] )
?>

Upvotes: 1

Related Questions