Beispiel #1
0
    public function init()
    {
        if (is_array($this->copyFrom)) {
            $id = Html::getInputId($this->model, $this->attribute);
            $buttonId = $id . '-copyButton';
            $this->addon['append'] = ['content' => Html::button(Icon::show('code'), ['class' => 'btn btn-primary', 'id' => $buttonId]), 'asButton' => true];
            $encodedFrom = Json::encode($this->copyFrom);
            $encodedTo = Json::encode('#' . $id);
            $js = <<<EOT
\$("#{$buttonId}").click(function(){
Admin.copyFrom(
    {$encodedFrom},
    {$encodedTo}
);
});
EOT;
            $this->form->getView()->registerJs($js);
        } elseif (is_array($this->makeSlug)) {
            $id = Html::getInputId($this->model, $this->attribute);
            $buttonId = $id . '-slugButton';
            $this->addon['append'] = ['content' => Html::button(Icon::show('code'), ['class' => 'btn btn-primary', 'id' => $buttonId]), 'asButton' => true];
            $encodedFrom = Json::encode($this->makeSlug);
            $encodedTo = Json::encode('#' . $id);
            $js = <<<EOT
\$("#{$buttonId}").click(function(){
Admin.makeSlug(
    {$encodedFrom},
    {$encodedTo}
);
});
EOT;
            $this->form->getView()->registerJs($js);
        }
        parent::init();
    }
Beispiel #2
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     if ($this->url === null) {
         throw new InvalidConfigException("You must setup the 'Url' property.");
     }
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();
     }
     parent::init();
 }
Beispiel #3
0
 public function init()
 {
     echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     echo Html::error($this->model, $this->attribute, $this->options);
     $id = Html::getInputId($this->model, $this->attribute);
     echo FileInput::widget(['name' => 'file', 'options' => ['accept' => 'image/*', 'multiple' => false], 'pluginEvents' => ['fileuploaded' => 'function(event, data, previewId, index) {
                 $("#' . $id . '").val(data.response.url);
             }'], 'pluginOptions' => ['initialPreview' => $this->model->{$this->attribute} ? [Html::img($this->model->{$this->attribute}, ['class' => 'file-preview-image'])] : false, 'maxFileCount' => 1, 'minFileCount' => 1, 'previewFileType' => 'image', 'multiple' => false, 'showPreview' => true, 'showUploadedThumbs' => false, 'uploadUrl' => \yii\helpers\Url::to(['/system/image/upload'])]]);
     parent::init();
 }
Beispiel #4
0
 * @var $property_id integer
 * @var $property_key string
 * @var $this \app\properties\handlers\Handler
 * @var $values array
 */
?>

<?php 
// little style fix
if (!$multiple) {
    echo '<style>.field-' . \kartik\helpers\Html::getInputId($model, $property_key) . ' .select2-container .select2-choice .select2-arrow b {background: none;}</style>';
}
?>

    <div class="form-group field-<?php 
echo \kartik\helpers\Html::getInputId($model, $property_key);
?>
">
        <?php 
if ($multiple) {
    ?>
            <?php 
    echo \yii\helpers\Html::hiddenInput(\yii\helpers\Html::getInputName($model, $property_key), '');
    ?>
        <?php 
}
?>
        <?php 
echo \yii\helpers\Html::activeLabel($model, $property_key, ['class' => 'col-md-2 control-label']);
?>
        <div class="col-md-10">
 /**
  * Initializes the widget options.
  */
 public function initOptions()
 {
     Html::addCssClass($this->labelOptions, 'control-label');
     Html::addCssClass($this->separatorOptions, 'kv-field-separator');
     if (isset(self::$_inputWidgets[$this->type])) {
         $this->widgetClass = $this->type;
     }
     if ($this->_isInput && empty($this->options1['class'])) {
         Html::addCssClass($this->options1, 'form-control');
     }
     if ($this->_isInput && empty($this->options2['class'])) {
         Html::addCssClass($this->options2, 'form-control');
     }
     if (empty($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if (empty($this->options1['id'])) {
         $this->options1['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute1) : $this->options['id'] . '-1';
     }
     if (empty($this->options2['id'])) {
         $this->options2['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute2) : $this->options['id'] . '-2';
     }
     if (empty($this->errorContainer['id'])) {
         $this->errorContainer['id'] = $this->options1['id'] . '-error';
     }
     $this->container['id'] = $this->options['id'] . '-container';
 }
Beispiel #6
-1
    public function init()
    {
        $fields = ['copyFrom' => ['buttonIdSuffix' => '-copyButton', 'buttonIcon' => 'code', 'jsMethodName' => 'Admin.copyFrom'], 'makeSlug' => ['buttonIdSuffix' => '-slugButton', 'buttonIcon' => 'code', 'jsMethodName' => 'Admin.makeSlug'], 'makeKey' => ['buttonIdSuffix' => '-keyButton', 'buttonIcon' => 'code', 'jsMethodName' => 'Admin.makeKey']];
        foreach ($fields as $fieldName => $params) {
            if (true === is_array($this->{$fieldName})) {
                $id = Html::getInputId($this->model, $this->attribute);
                $buttonId = $id . $params['buttonIdSuffix'];
                $this->addon['append'] = ['content' => Html::button(Icon::show($params['buttonIcon']), ['class' => 'btn btn-primary', 'id' => $buttonId]), 'asButton' => true];
                $encodedFrom = Json::encode($this->{$fieldName});
                $encodedTo = Json::encode('#' . $id);
                $js = <<<EOT
\$("#{$buttonId}").click(function() {
    {$params['jsMethodName']}({$encodedFrom}, {$encodedTo});
});
EOT;
                $this->form->getView()->registerJs($js);
            }
        }
        parent::init();
    }