/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DisciplinaOpcao::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]); $query->andFilterWhere(['like', 'nome', $this->nome]); return $dataProvider; }
/** * Finds the DisciplinaOpcao model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return DisciplinaOpcao the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DisciplinaOpcao::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getOpcao0() { return $this->hasOne(DisciplinaOpcao::className(), ['id' => 'opcao']); }
/* @var $model backend\models\Disciplina */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="disciplina-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'nome')->textInput(['maxlength' => true]); ?> <?php $opcaoArray = ArrayHelper::map(\backend\models\DisciplinaOpcao::find()->orderBy('nome')->all(), 'id', 'nome'); ?> <?php echo $form->field($model, 'opcao')->dropDownList($opcaoArray, ['prompt' => '---- Selecione uma Opcao ----'])->label('Opção'); ?> <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(); ?>