Beispiel #1
0
 public function init()
 {
     parent::init();
     $languages = Yii::$app->yee->languages;
     $isCurrentLanguage = Yii::$app->language == $this->language;
     if ($this->language !== NULL && ($this->model->isMultilingual() || $this->multilingual)) {
         $languageLabel = $languages[$this->language];
         $inputLabel = $this->model->getAttributeLabel($this->attribute) . (count($languages) > 1 ? " [{$languageLabel}]" : '');
         $this->labelOptions = array_merge($this->labelOptions, ['label' => $inputLabel]);
         $this->options = array_merge($this->options, ['data-toggle' => 'multilang', 'data-lang' => $this->language, 'class' => $isCurrentLanguage ? 'in' : '']);
         $langPart = strtolower(str_replace('-', '_', $this->language));
         $this->attribute .= $isCurrentLanguage ? '' : '_' . $langPart;
     }
 }
 public function init()
 {
     parent::init();
     $this->errorOptions = ArrayHelper::merge($this->errorOptions, ['tag' => 'span']);
     $this->hintOptions = ArrayHelper::merge($this->hintOptions, ['tag' => 'span']);
     $hint = $this->model->getAttributeHint($this->attribute);
     if ($hint) {
         $this->parts['{hint}'] = Html::tag('span', AmosIcons::show('help-alt'), ['data-toggle' => "tooltip", 'data-placement' => "top", 'title' => html_entity_decode($hint)]);
     }
     $error = $this->model->getErrors($this->attribute);
     if (count($error)) {
         $this->parts['{error}'] = Html::tag('span', AmosIcons::show('alert'), ['data-toggle' => "tooltip", 'data-placement' => "top", 'title' => html_entity_decode(implode("\n", $error))]);
     }
 }
Beispiel #3
0
 /**
  * Added translation for label title.
  * @inheritdoc
  */
 protected function renderLabelParts($label = null, $options = [])
 {
     parent::renderLabelParts($label, $options);
     if (!empty($this->parts['{labelTitle}'])) {
         $this->parts['{labelTitle}'] = Yii::tr($this->parts['{labelTitle}']);
     }
 }
 /**
  * @inheritdoc
  */
 public function listBox($items, $options = [])
 {
     return parent::listBox($items, array_merge($this->listBoxOptions, $options));
 }
Beispiel #5
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!in_array($this->layout, ['default', 'horizontal', 'inline'])) {
         throw new InvalidConfigException('Invalid layout type: ' . $this->layout);
     }
     if ($this->layout !== 'default') {
         Html::addCssClass($this->options, 'form-' . $this->layout);
     }
     if (!isset($this->fieldConfig['class'])) {
         $this->fieldConfig['class'] = ActiveField::className();
     }
     parent::init();
 }
Beispiel #6
0
$this->title = Yii::t('back', 'add photos into gallery');
$this->params['breadcrumbs'][] = ['label' => Yii::t('back', 'Galleries'), 'url' => ['gallery/index']];
$this->params['breadcrumbs'][] = ['label' => $gallery->title . ' - ' . Yii::t('back', 'photos in gallery'), 'url' => ['gallery/photos', 'id' => $model->item_id]];
$this->params['breadcrumbs'][] = $this->title;
FormAsset::register($this);
?>

<div>

	<h1><?php 
echo Html::encode($this->title);
?>
</h1>

	<?php 
$form = ActiveForm::begin(['fieldClass' => ActiveField::className()]);
?>

	<div class="form-group">
		<?php 
echo Html::checkbox('selectAll', null, ['class' => 'selectAll']) . ' ' . Yii::t('back', 'select all images on this page');
?>
	</div>

	<div class="row">
		<div class="col-xs-12">
			<?php 
echo ListView::widget(['dataProvider' => $dataProvider, 'itemView' => '_photo', 'viewParams' => compact('form'), 'layout' => "<div class=\"row\">{items}</div>\n{pager}"]);
?>
		</div>
	</div>
Beispiel #7
0
 /**
  * @param \netis\crud\db\ActiveRecord $model
  * @param string                      $attribute
  * @param array                       $options
  * @param bool                        $multiple
  *
  * @return \yii\bootstrap\ActiveField
  * @throws InvalidConfigException
  */
 public static function createActiveField($model, $attribute, $options = [], $multiple = false)
 {
     /** @var Formatter $formatter */
     $formatter = Yii::$app->formatter;
     $stubForm = new \stdClass();
     $stubForm->layout = 'default';
     /** @var \yii\bootstrap\ActiveField $field */
     $field = Yii::createObject(['class' => \yii\bootstrap\ActiveField::className(), 'model' => $model, 'attribute' => $attribute, 'form' => $stubForm]);
     $attributeName = Html::getAttributeName($attribute);
     $attributeFormat = $model->getAttributeFormat($attributeName);
     $format = is_array($attributeFormat) ? $attributeFormat[0] : $attributeFormat;
     $column = $model->getTableSchema()->getColumn($attributeName);
     switch ($format) {
         case 'boolean':
             if ($multiple) {
                 $field->inline()->radioList(['0' => $formatter->booleanFormat[0], '1' => $formatter->booleanFormat[1], '' => Yii::t('app', 'Any')], $options);
             } else {
                 $field->checkbox($options);
             }
             break;
         case 'shortLength':
             $value = Html::getAttributeValue($model, $attribute);
             if (!isset($options['value'])) {
                 $options['value'] = $value === null ? null : $formatter->asMultiplied($value, 1000);
             }
             $field->textInput($options);
             $field->inputTemplate = '<div class="input-group">{input}<span class="input-group-addon">m</span></div>';
             break;
         case 'shortWeight':
             $value = Html::getAttributeValue($model, $attribute);
             if (!isset($options['value'])) {
                 $options['value'] = $value === null ? null : $formatter->asMultiplied($value, 1000);
             }
             $field->textInput($options);
             $field->inputTemplate = '<div class="input-group">{input}<span class="input-group-addon">kg</span></div>';
             break;
         case 'multiplied':
             $value = Html::getAttributeValue($model, $attribute);
             if (!isset($options['value'])) {
                 $options['value'] = $value === null ? null : $formatter->asMultiplied($value, $attributeFormat[1]);
             }
             $field->textInput($options);
             break;
         case 'integer':
             if (!isset($options['value'])) {
                 $options['value'] = Html::getAttributeValue($model, $attribute);
             }
             $field->textInput($options);
             break;
         case 'time':
             if (!isset($options['value'])) {
                 $options['value'] = Html::encode(Html::getAttributeValue($model, $attribute));
             }
             $field->textInput($options);
             break;
         case 'datetime':
         case 'date':
             if (!isset($options['value'])) {
                 $value = Html::getAttributeValue($model, $attribute);
                 if (!$model->hasErrors($attribute) && $value !== null) {
                     $value = $formatter->format($value, $format);
                 }
                 $options['value'] = $value;
             }
             if (!isset($options['class'])) {
                 $options['class'] = 'form-control';
             }
             $field->parts['{input}'] = array_merge(['class' => \omnilight\widgets\DatePicker::className(), 'model' => $model, 'attribute' => $attributeName, 'options' => $options], $format !== 'datetime' ? [] : ['class' => \kartik\datetime\DateTimePicker::className(), 'convertFormat' => true]);
             break;
         case 'enum':
             $items = $formatter->getEnums()->get($attributeFormat[1]);
             if ($multiple) {
                 $options = array_merge(['class' => 'select2', 'placeholder' => self::getPrompt(), 'multiple' => 'multiple'], $options);
                 $field->parts['{input}'] = ['class' => \maddoger\widgets\Select2::className(), 'model' => $model, 'attribute' => $attribute, 'items' => $items, 'clientOptions' => ['allowClear' => true, 'closeOnSelect' => true], 'options' => $options];
             } else {
                 if ($column !== null && $column->allowNull) {
                     $options['prompt'] = self::getPrompt();
                 }
                 $field->dropDownList($items, $options);
             }
             break;
         case 'flags':
             throw new InvalidConfigException('Flags format is not supported by ' . get_called_class());
         case 'paragraphs':
             if (!isset($options['value'])) {
                 $options['value'] = Html::encode(Html::getAttributeValue($model, $attribute));
             }
             if ($multiple) {
                 $field->textInput($options);
             } else {
                 $field->textarea(array_merge(['cols' => '80', 'rows' => '10'], $options));
             }
             break;
         case 'file':
             if (!isset($options['value'])) {
                 $options['value'] = Html::getAttributeValue($model, $attribute);
             }
             $field->fileInput($options);
             break;
         default:
         case 'text':
             if (!isset($options['value'])) {
                 $options['value'] = Html::getAttributeValue($model, $attribute);
             }
             if ($column && $column->type === 'string' && $column->size !== null) {
                 $options['maxlength'] = $column->size;
             }
             $field->textInput($options);
             break;
     }
     return $field;
 }
Beispiel #8
0
use backend\assets\FormAsset;
use common\models\WebRecord;
use yii\bootstrap\ActiveField;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\WebRecord */
/* @var $form yii\bootstrap\ActiveForm */
FormAsset::register($this);
?>

<div>

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal', 'fieldClass' => ActiveField::className(), 'fieldConfig' => Yii::$app->params['fieldConfig'], 'options' => ['id' => 'web-form']]);
?>

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

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

    <?php 
echo $form->field($model, 'theme')->dropDownList(Yii::$app->params['themeOptions']);
?>

    <?php 
 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->begin($this->config);
     if ($this->displayErrorSummary) {
         echo $this->errorSummary($this->model);
     }
     foreach ($this->fields as $field) {
         if (is_array($field)) {
             if (!method_exists(ActiveField::className(), $field[1])) {
                 echo $this->field($this->model, $field[0], isset($field[2]) ? $field[2] : [])->widget($field[1], isset($field[3]) ? $field[3] : []);
             } else {
                 if (!stripos($field[1], 'list')) {
                     echo $this->field($this->model, $field[0], isset($field[2]) ? $field[2] : [])->{$field}[1](isset($field[3]) ? $field[3] : []);
                 } else {
                     echo $this->field($this->model, $field[0], isset($field[3]) ? $field[3] : [])->{$field}[1](isset($field[2]) ? $field[2] : [], isset($field[4]) ? $field[4] : []);
                 }
             }
         } elseif (is_string($field)) {
             echo $this->field($this->model, $field)->textInput();
         } else {
             throw new InvalidConfigException('Each field should be either a string or array.');
         }
     }
     echo Html::beginTag('div', $this->buttonGroupOptions);
     foreach ($this->buttons as $btn) {
         echo $btn;
     }
     echo Html::endTag('div');
     parent::run();
 }
Beispiel #10
0
 public function bitMask($items, $options = [])
 {
     $result = [];
     foreach ($items as $id => $name) {
         if ($this->model->{$this->attribute} & 1 << (int) $id - 1) {
             $result[] = $id;
         }
     }
     $this->model->{$this->attribute} = $result;
     return parent::checkboxList($items, $options);
 }
Beispiel #11
0
		</div>
	</div>

	<?php 
if ($periodModel->existsActualPlans()) {
    ?>
		<div class="row">
			<div class="col-xs-12">

				<h2><?php 
    echo Module::t('res', 'Usage overview');
    ?>
</h2>

				<?php 
    $form = ActiveForm::begin(['layout' => 'inline', 'fieldClass' => ActiveField::className(), 'fieldConfig' => ['labelOptions' => ['class' => ''], 'enableError' => true]]);
    ?>

				<?php 
    echo $form->field($periodModel, 'firstDate')->widget(DateControl::className(), ['type' => DateControl::FORMAT_DATE, 'language' => Yii::$app->language]);
    ?>

				<?php 
    echo $form->field($periodModel, 'lastDate')->widget(DateControl::className(), ['type' => DateControl::FORMAT_DATE, 'language' => Yii::$app->language]);
    ?>

				<?php 
    echo Html::submitButton(Module::t('res', 'OK'), ['class' => 'btn btn-default', 'style' => 'position: relative; top: -5px;']);
    ?>

				<?php 
Beispiel #12
0
 public function init()
 {
     parent::init();
 }
 /**
  * @inheritdoc
  */
 public function widget($class, $config = [])
 {
     $config = array_merge(['options' => $this->inputOptions], $config);
     return parent::widget($class, $config);
 }
 public function checkbox($options = [], $enclosedByLabel = true)
 {
     $options['template'] = "<div class=\"checkbox\">\n{beginLabel}\n{input}\n<span class=\"checkbox-material\"></span>{labelTitle}\n{endLabel}\n{error}\n{hint}\n</div>";
     return parent::checkbox($options, $enclosedByLabel);
 }