/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Type::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'typeCreate' => $this->typeCreate, 'typeUpdate' => $this->typeUpdate]); $query->andFilterWhere(['like', 'typeName', $this->typeName])->andFilterWhere(['like', 'typeDesc', $this->typeDesc]); return $dataProvider; }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use common\models\Service; use common\models\Type; $types = ArrayHelper::map(Type::find()->asArray()->all(), 'type_id', 'title'); $services = ArrayHelper::map(Service::find()->where(['parent_id' => 0])->asArray()->all(), 'id', 'title'); ?> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <div class="row"> <div class="col-md-4"> <?php echo $form->field($model, 'landing_id')->textInput(['readonly' => true]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'type_id')->dropDownList($types); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'service_id')->dropDownList($services); ?> </div>
$blocks_array = $query->all(); // Подгрузка параметров из конфига $phone = \Yii::$app->params['phone']; // Меню лендинга $menu = array(); // Добавление пунктов foreach ($blocks_array as $block_array){ // Тип блока $type = Type::findOne($block_array->type_id); if (($block_array->menu_label) and ($type->code)) { $menu[] = [ 'label' => $block_array->menu_label, 'url' => '#' . $type->code, 'options' => [ 'class' => $block_array->menu_class, ] ]; } } ?> <nav id="header" class="navbar navbar-inverse navbar-fixed-top">
/** * Finds the Type model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Type the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Type::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use common\models\Type; $type = Type::findOne($model->type_id); ?> <!-- Содержание --> <?php echo $this->render('block/' . $type->code, ['model' => $model]);
use yii\helpers\Html; use yii\widgets\ActiveForm; use common\models\Block; use common\models\Type; use yii\data\ActiveDataProvider; use yii\widgets\ListView; use yii\grid\GridView; use yii\grid\ActionColumn; // Получаем переменные $blocks_selected = new ActiveDataProvider(['query' => Block::find()->where(['landing_id' => $model->landing_id])->orderBy('sort'), 'pagination' => ['pageSize' => 100]]); $blocks_selected_array = Type::getLandingBlocks($model->landing_id)->asArray()->all(); $blocks_id_selected = array(); foreach ($blocks_selected_array as $block_selected_array) { $blocks_id_selected[] = $block_selected_array['type_id']; } $blocks_not_selected = new ActiveDataProvider(['query' => Type::getNotLandingBlocks($blocks_id_selected)]); // ?> <?php $form = ActiveForm::begin(); ?> <div class="row"> <div class="col-md-4"> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> </div> <div class="col-md-4"> <?php
?> <?php if ($model->documentImage) { echo '<img src="' . \Yii::$app->request->BaseUrl . '/' . $model->documentImage . '" width="90px"> '; //echo Html::a('Delete Logo', ['uploads/', 'id'=>$model->id, 'field'=> 'documentImage'], ['class'=>'btn btn-danger']).'<p>'; } ?> <?php echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\common\models\Category::find()->all(), 'id', 'categoryName'), ['prompt' => 'Category']); ?> <?php echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(\common\models\Type::find()->all(), 'id', 'typeName'), ['prompt' => 'Type']); ?> <?php echo $form->field($model, 'priority_id')->dropDownList(ArrayHelper::map(\common\models\Priority::find()->all(), 'id', 'priorityName'), ['prompt' => 'Priority']); ?> <?php echo $form->field($model, 'companyAgency_id')->dropDownList(ArrayHelper::map(\common\models\Companyagency::find()->all(), 'id', 'companyAgencyName'), ['prompt' => 'Company Agency']); ?> <?php echo $form->field($model, 'section_id')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> <div class="form-group">
<div class="col-md-6"> <?php echo $form->field($model, 'phone'); ?> </div> </div> <h2><?php echo Yii::t('app', 'Wishes to the object'); ?> </h2> <div class="row"> <div class="col-md-12"> <?php echo $form->field($model, 'type_ids')->checkboxList(\common\models\Type::getList())->inline(); ?> </div> </div> <div class="row"> <div class="col-md-6"> <?php echo $form->field($model, 'rooms'); ?> </div> <div class="col-md-6"> <?php echo $form->field($model, 'budget'); ?> </div>
public function getTypes() { return $this->hasMany(Type::className(), ['id' => 'type_id'])->viaTable('application_type', ['application_id' => 'id']); }
static function getNotLandingBlocks($blocks_id_selected) { $models = Type::find()->where(['not in', 'type_id', $blocks_id_selected]); return $models; }
/** * @return \yii\db\ActiveQuery */ public function getType() { return $this->hasOne(Type::className(), ['type_id' => 'type_id']); }
echo $form->field($model, 'file')->fileInput(); ?> </div> <div class="column2"> <?php echo $form->field($model, 'profilenumber')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?> <?php echo $form->field($model, 'sex')->dropDownList(['Male' => 'Male', 'Female' => 'Female'], ['prompt' => 'Select your sex', 'style' => 'width: 300px']); ?> <?php $type = Type::find()->all(); $listData = ArrayHelper::map($type, 'type_id', 'type_name'); echo $form->field($model, 'type_id')->dropDownList($listData, ['prompt' => 'Select position', 'style' => 'width: 300px']); ?> <?php $precinct = Precinct::find()->all(); $listData = ArrayHelper::map($precinct, 'precinct_id', 'precinctnumber'); echo $form->field($model, 'precinct_id')->dropDownList($listData, ['prompt' => 'Select your precinct', 'style' => 'width: 300px']); ?> </div> <div class="column3"> <?php echo $form->field($model, 'mothers_maiden_name')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?>