/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Campaigntypes::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['CampaignTypeId' => $this->CampaignTypeId, 'created_by' => $this->created_by, 'LastUpdatedBy' => $this->LastUpdatedBy, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'deleted_at' => $this->deleted_at]); $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'Description', $this->Description])->andFilterWhere(['like', 'Comment', $this->Comment]); return $dataProvider; }
/** * Finds the Campaigntypes model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Campaigntypes the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Campaigntypes::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use yii\bootstrap\ActiveForm; use yii\helpers\ArrayHelper; use common\models\Campaigntypes; /* @var $this yii\web\View */ /* @var $model common\models\Campaigns */ /* @var $form yii\bootstrap\ActiveForm */ $data = ArrayHelper::map(Campaigntypes::find()->asArray()->all(), 'CampaignTypeId', 'Name'); ?> <div class="campaigns-form"> <?php $form = ActiveForm::begin(['layout' => 'horizontal']); ?> <?php echo $form->field($model, 'CampaignTypeId', ['horizontalCssClasses' => ['wrapper' => 'col-sm-3']])->dropDownList($data, ['prompt' => 'Choose A Campaign Type']); ?> <?php echo $form->field($model, 'Name', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->textInput(['maxlength' => 500]); ?> <?php echo $form->field($model, 'ShortDescription', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->textInput(['maxlength' => 500]); ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getCampaignType() { return $this->hasOne(Campaigntypes::className(), ['CampaignTypeId' => 'CampaignTypeId']); }