/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Position::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(['position_id' => $this->position_id]); $query->andFilterWhere(['like', 'position_name', $this->position_name]); return $dataProvider; }
?> <?php echo $form->field($model, 'nickname')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'rank')->dropDownList(Rank::getList()); ?> <?php echo $form->field($model, 'unit')->dropDownList($units); ?> <?php echo $form->field($model, 'position')->dropDownList(Position::getList()); ?> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => true]); ?> <?php /*= $form->field($model, 'photos')->textInput() */ ?> <?php /*= $form->field($model, 'primary_photo')->textInput() */ ?> <?php
?> <?php echo $form->field($model, 'name', ['options' => ['class' => 'col-md-2']]); ?> <?php echo $form->field($model, 'nickname', ['options' => ['class' => 'col-md-2']]); ?> <?php echo $form->field($model, 'rank', ['options' => ['class' => 'col-md-2']])->dropDownList(Rank::getList()); ?> <?php echo $form->field($model, 'position', ['options' => ['class' => 'col-md-2']])->dropDownList(Position::getList()); ?> <?php echo $form->field($model, 'unit', ['options' => ['class' => 'col-md-2']])->dropDownList($units); ?> <?php // echo $form->field($model, 'phone') ?> <?php // echo $form->field($model, 'photos') ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getPosition() { return $this->hasOne(Position::className(), ['position_id' => 'position_id']); }
/** * Finds the Position model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Position the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Position::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php $form = ActiveForm::begin(); ?> <div class="column1"> <?php echo $form->field($model, 'id_number')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?> <?php echo $form->field($model, 'lastname')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?> <?php $position = Position::find()->all(); $listData = ArrayHelper::map($position, 'position_id', 'position_name'); echo $form->field($model, 'position_id')->dropDownList($listData, ['prompt' => 'Select Position', 'style' => 'width: 300px']); ?> </div> <div class="column2"> <?php echo $form->field($model, 'user_id')->textInput(['style' => 'width: 300px']); ?> <?php echo $form->field($model, 'firstname')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?> <?php echo $form->field($model, 'employee_status')->dropDownList(['Active' => 'Active', 'Inactive' => 'Inactive'], ['prompt' => 'Select status', 'style' => 'width: 300px']); ?>
$form = ActiveForm::begin(); ?> <!--<?php echo $form->field($model, 'position_id')->dropDownList(ArrayHelper::map(\common\models\Position::find()->all(), 'id', 'positionName'), ['prompt' => 'Position']); ?> --> <!--<?php echo $form->field($model, 'section_id')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> --> <?php //$form->field($model, 'position_id') echo $form->field($model, 'position_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Position::find()->all(), 'id', 'positionName'), 'options' => ['placeholder' => 'Select a position'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php //$form->field($model, 'section_id') echo $form->field($model, 'section_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), 'options' => ['placeholder' => 'Select a section'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'userFName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'userMName')->textInput(['maxlength' => true]); ?>
use yii\widgets\DetailView; use common\models\Rank; use common\models\Position; /* @var $this yii\web\View */ /* @var $model common\models\Soldier */ $this->title = $model->name; $this->params['breadcrumbs'][] = ['label' => 'Службовець', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="soldier-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('Правити', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Видалити', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Ви впевнені що хочете видалити цього службовця?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['name', 'nickname', ['attribute' => 'rank', 'value' => Rank::getTextValue($model->rank)], ['attribute' => 'unit', 'value' => $model->getUnitLink(), 'format' => 'html'], ['attribute' => 'position', 'value' => Position::getTextValue($model->position)], 'phone', 'email:email']]); ?> </div>