Class yeesoft\media\widgets\FileInput

Inheritanceyeesoft\media\widgets\FileInput » yii\widgets\InputWidget

Class FileInput

Basic example of usage:

<?= FileInput::widget([

 'name' => 'image',
 'buttonTag' => 'button',
 'buttonName' => 'Browse',
 'buttonOptions' => ['class' => 'btn btn-default'],
 'options' => ['class' => 'form-control'],
 // Widget template
 'template' => '<div class="input-group">{input}<span class="input-group-btn">{button}</span></div>',
 // Optional, if set, only this image can be selected by user
 'thumb' => 'original',
 // Optional, if set, in container will be inserted selected image
 'imageContainer' => '.img',
 // Default to FileInput::DATA_URL. This data will be inserted in input field
 'pasteData' => FileInput::DATA_URL,
 // JavaScript function, which will be called before insert file data to input.
 // Argument data contains file data.
 // data example: [alt: "Witch with cat", description: "123", url: "/uploads/2014/12/vedma-100x100.jpeg", id: "45"]
 'callbackBeforeInsert' => 'function(e, data) {
 console.log( data );
 }',

]) ?>

This class provides media usage. You can optional select all media file info to your input field.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$buttonName string Button name yeesoft\media\widgets\FileInput
$buttonOptions array Button html options yeesoft\media\widgets\FileInput
$buttonTag string Button tag yeesoft\media\widgets\FileInput
$callbackBeforeInsert string JavaScript function, which will be called before insert file data to input. yeesoft\media\widgets\FileInput
$frameSrc array Selecte the frameSrc in case you use a different module name yeesoft\media\widgets\FileInput
$imageContainer string Optional, if set, in container will be inserted selected image yeesoft\media\widgets\FileInput
$options array Widget html options yeesoft\media\widgets\FileInput
$pasteData string This data will be inserted in input field yeesoft\media\widgets\FileInput
$resetButtonName string Reset button name yeesoft\media\widgets\FileInput
$resetButtonOptions array Reset button html options yeesoft\media\widgets\FileInput
$resetButtonTag string Reset button tag yeesoft\media\widgets\FileInput
$template string Widget template yeesoft\media\widgets\FileInput
$thumb string Optional, if set, only this image can be selected by user yeesoft\media\widgets\FileInput

Public Methods

Hide inherited methods

MethodDescriptionDefined By
init() yeesoft\media\widgets\FileInput
run() Runs the widget. yeesoft\media\widgets\FileInput

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DATA_ALT 'alt' yeesoft\media\widgets\FileInput
DATA_DESCRIPTION 'description' yeesoft\media\widgets\FileInput
DATA_ID 'id' yeesoft\media\widgets\FileInput
DATA_URL 'url' yeesoft\media\widgets\FileInput

Property Details

$buttonName public property

Button name

public string $buttonName 'Browse'
$buttonOptions public property

Button html options

public array $buttonOptions = ['class' => 'btn btn-default']
$buttonTag public property

Button tag

public string $buttonTag 'button'
$callbackBeforeInsert public property

JavaScript function, which will be called before insert file data to input. Argument data contains file data. data example: [alt: "Witch with cat", description: "123", url: "/uploads/2014/12/vedma-100x100.jpeg", id: "45"]

$frameSrc public property

Selecte the frameSrc in case you use a different module name

public array $frameSrc = ['/media/manage']
$imageContainer public property

Optional, if set, in container will be inserted selected image

public string $imageContainer ''
$options public property

Widget html options

public array $options = ['class' => 'form-control']
$pasteData public property

This data will be inserted in input field

public string $pasteData self::DATA_URL
$resetButtonName public property

Reset button name

public string $resetButtonName '<span class="text-danger glyphicon glyphicon-remove"></span>'
$resetButtonOptions public property

Reset button html options

public array $resetButtonOptions = ['class' => 'btn btn-default']
$resetButtonTag public property

Reset button tag

public string $resetButtonTag 'button'
$template public property

Widget template

public string $template '<div class="input-group">{input}<span class="input-group-btn">{button}{reset-button}</span></div>'
$thumb public property

Optional, if set, only this image can be selected by user

public string $thumb ''

Method Details

init() public method

public void init ( )
run() public method

Runs the widget.

public void run ( )