public function init()
 {
     if ($this->hasModel() && $this->model->hasMethod('getHexColor')) {
         $this->model->{$this->attribute} = $this->model->getHexColor();
     }
     parent::init();
 }
Exemplo n.º 2
0
    /**
     *
     * Registers the needed assets
     */
    public function registerAssets()
    {
        $view = $this->getView();
        $value = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value;
        $this->html5Options['value'] = $value;
        ColorInputAsset::register($view);
        if ($this->useNative) {
            parent::registerAssets();
            return;
        }
        \kartik\base\Html5InputAsset::register($view);
        $caption = 'jQuery("#' . $this->options['id'] . '")';
        $input = 'jQuery("#' . $this->html5Options['id'] . '")';
        $this->pluginOptions['change'] = new JsExpression("function(color){\n            _.delay(function()\n            {\n                {$caption}.val(color." . $this->saveValueAs . "());\n            }, 500);\n        }");
        $this->registerPlugin('spectrum', $input);
        $js = <<<JS
{$input}.spectrum('set','{$value}');
{$caption}.on('change', function(){
    {$input}.spectrum('set',{$caption}.val());
});
JS;
        $view->registerJs($js);
    }
Exemplo n.º 3
0
?>

	<input type="hidden" name="titleChanged" value="false" id="titleChanged">
	<?php 
if ($model->isNewRecord) {
    $pluginOptions = ['showUpload' => false, 'initialPreviewShowDelete' => true, 'previewFileType' => 'image'];
} else {
    $pluginOptions = ['showUpload' => false, 'initialPreview' => [Html::img(Yii::getAlias('@web') . "/img/titulo/" . $model->picture, ['class' => 'file-preview-image', 'alt' => $model->picture])], 'initialPreviewShowDelete' => true, 'previewFileType' => 'image'];
}
?>
	<?php 
echo $form->field($model, 'title')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => $pluginOptions, 'pluginEvents' => ['fileclear' => 'function(){$("#titleChanged").val("true")}', 'fileloaded' => 'function(){$("#titleChanged").val("true")}']]);
?>

    <?php 
echo $form->field($model, 'color')->widget(ColorInput::classname(), ['options' => ['placeholder' => 'Selecciona un color...']]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(['ACTIVE' => 'ACTIVE', 'INACTIVE' => 'INACTIVE'], ['prompt' => '']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Exemplo n.º 4
0
echo $form->field($model, 'firstname')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'lastname')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'address')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'tel')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'color')->widget(ColorInput::classname(), ['options' => ['placeholder' => 'เลือกสีที่ชอบ']]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'เพิ่มข้อมูล' : 'แก้ไข', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 5
0
<div class="category-form">

<div class="col-md-8">

    <?php 
$form = ActiveForm::begin(['id' => 'categoryform', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-4\">{input}</div>\n<div class=\"col-lg-7\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>


    <?php 
echo $form->field($model, 'desc_category')->textInput(['maxlength' => 45]);
?>

    <?php 
echo $form->field($model, 'hexcolor_category')->widget(ColorInput::classname(), ['options' => ['placeholder' => Yii::t('app', 'Select')]]);
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(app\models\Category::find()->where(['parent_id' => null, 'user_id' => Yii::$app->user->identity->id, 'is_active' => 1])->orderBy("desc_category ASC")->all(), 'id_category', 'desc_category'), ['prompt' => Yii::t('app', 'None')]);
?>

    <?php 
echo $form->field($model, 'is_active')->radioList(['1' => Yii::t('app', 'Yes'), '0' => Yii::t('app', 'No')], ['itemOptions' => ['class' => 'radio-inline', 'labelOptions' => array('style' => 'padding:5px;')]]);
?>

    <div class="form-group">
        <div class="col-lg-offset-2 col-lg-10">
        <?php 
echo Html::submitButton($model->isNewRecord ? '<i class="fa fa-floppy-o"></i> ' . Yii::t('app', 'Save') : '<i class="fa fa-floppy-o"></i> ' . Yii::t('app', 'Save'), ['class' => $model->isNewRecord ? 'btn btn-primary grid-button' : 'btn btn-primary grid-button']);
?>
Exemplo n.º 6
0
echo $form->field($model, 'area');
?>
        <?php 
echo $form->field($model, 'city');
?>
        <?php 
echo $form->field($model, 'zipcode');
?>
        <?php 
echo $form->field($model, 'dob')->widget(\yii\jui\DatePicker::classname(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control'], 'clientOptions' => ['changeYear' => true, 'changeMonth' => true, 'maxDate' => '+0d']]);
?>
        <?php 
echo $form->field($model, 'mobile');
?>
        <?php 
echo $form->field($model, 'color')->widget(ColorInput::classname(), ['options' => ['placeholder' => 'Select color ...'], 'pluginOptions' => ['showUpload' => false, 'previewFileType' => 'image']]);
?>
        <?php 
echo $form->field($model, 'image')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*', 'multiple' => true], 'pluginOptions' => ['allowedFileExtensions' => ['jpg', 'gif', 'png']]]);
?>

        <div class="col-lg-12 form-group">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => 'btn btn-primary pull-right']);
?>
        </div>

        <?php 
ActiveForm::end();
?>
    </div>
Exemplo n.º 7
0
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'user_id', ['template' => "{input}"])->hiddenInput(['value' => Yii::$app->getUser()->id])->label('')->error(false);
?>

    <?php 
echo $form->field($model, 'currencyId')->widget(Select2::classname(), ['data' => UserHelper::getCurrentListCurrency(), 'options' => ['placeholder' => 'Выберите валюту ...']]);
?>

    <?php 
echo $form->field($model, 'color')->widget(ColorInput::classname(), ['options' => ['placeholder' => 'Выберите цвет ...']]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Обновить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 8
0
<div class="theme-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($themeModel, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($themeModel, 'description')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($themeModel, 'color')->widget(ColorInput::classname(), ['options' => ['placeholder' => Yii::t("app", "Select color ...")], 'pluginOptions' => ['preferredFormat' => 'hex']])->hint(Yii::t("app", "Your theme main color. Value must be a 6 character hex value starting with a '#'."));
?>

    <div class="form-group">
        <label class="control-label"><?php 
echo Yii::t("app", "Live Preview");
?>
</label>
        <?php 
echo Select2::widget(['name' => 'preview', 'data' => $data, 'options' => ['placeholder' => Yii::t("app", "Choose a form")], 'pluginOptions' => ['allowClear' => true], 'pluginEvents' => ["select2:select" => "previewSelected", "select2:unselect" => "previewUnselected"]]);
?>
    </div>

    <!-- Preview panel -->
    <div class="panel panel-default" id="preview-container" style="display:none;">
        <div class="panel-heading clearfix">
Exemplo n.º 9
0
<div class="product-image-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <div class="col-md-6">
		<?php 
echo $form->field($model, 'image', ['template' => '{label}<div class="picturecut_image_container" ' . (!$model->isNewRecord ? 'style="background-image:url(' . $model->getImage() . ')"' : '') . '></div>{input}{error}{hint}'])->textInput(['maxlength' => true, 'readonly' => true]);
?>
		<?php 
// echo $form->field($model, 'image_path')->textInput(['maxlength' => true, 'readonly' => true])
?>
		<?php 
echo $form->field($model, 'color_code')->widget(ColorInput::classname(), ['options' => ['readonly' => true, 'placeholder' => ''], 'pluginOptions' => []]);
?>
		<?php 
echo $form->field($model, 'product_id')->textInput(['readonly' => true, 'type' => 'hidden'])->label(false);
?>
    </div>
    
    <div class="col-md-12">
        <div class="form-group">
            <?php 
echo Html::submitButton($model->isNewRecord ? 'Thêm mới' : 'Cập nhật', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        </div>
    </div>

    <?php 
Exemplo n.º 10
0
    <?php 
$form = ActiveForm::begin();
?>

    <div class="row">
        <div class="col-sm-2">
    	<?php 
echo $form->field($model, 'desc_type')->textInput(['maxlength' => 45]);
?>
    	</div>
    </div>
    <div class="row">
        <div class="col-sm-2">
	    <?php 
//$form->field($model, 'hexcolor_type')->textInput(['maxlength' => 45])
echo $form->field($model, 'hexcolor_type')->widget(ColorInput::classname(), ['options' => ['placeholder' => 'Selecione']]);
?>
	    </div>
    </div>

    <?php 
// $form->field($model, 'icon_type')->textInput(['maxlength' => 45])
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', '<i class="fa fa-floppy-o"></i> Gravar') : Yii::t('app', '<i class="fa fa-floppy-o"></i> Gravar'), ['class' => $model->isNewRecord ? 'btn btn-primary grid-button btn-sm' : 'btn btn-primary grid-button btn-sm']);
?>
    </div>

    <?php 
Exemplo n.º 11
-1
<div class="box box-default">
    <div class="box-header with-border">
        <h3 class="box-title"><?php 
echo $this->params['box-title'];
?>
</h3>
    </div>
    <div class="box-body">
        <?php 
echo $form->field($domain, 'name')->textInput(['size' => 30, 'maxlength' => 60]);
?>
        <?php 
echo $form->field($domain, 'default_policy')->dropDownList($domain->getPolicyOptions());
?>
        <?php 
echo $form->field($domain, 'color')->widget(ColorInput::classname(), ['options' => ['placeholder' => 'Select color ...', 'readonly' => true]]);
?>
    </div>
    <div class="box-footer">
        <div class="form-group">
            <div class="col-sm-offset-3 col-sm-6">
                <button type="submit" class="btn btn-primary"><?php 
echo Yii::t("topology", 'Save');
?>
</button>
            </div>
        </div>
    </div>
</div>

<?php