/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = RegistrationType::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, 'cost' => $this->cost]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery * Podemos llamar a su valor mediante $model->registrationType->name por ejemplo */ public function getRegistrationType() { return $this->hasOne(RegistrationType::className(), ['id' => 'registration_type_id']); }
requires_invoice.change(function(){ toggleInvoice(); }) '); ?> <div class="registration-form"> <?php $form = ActiveForm::begin(['layout' => 'horizontal', 'options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($registration_model, 'registration_type_id')->radioList(ArrayHelper::map(RegistrationType::find()->all(), 'id', 'name')); ?> <?php echo $form->field($registration_model, 'organization_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($registration_model, 'first_name')->textInput(['maxlength' => true, 'onChange' => "\$('#registration-display_name').val(\n \$('#registration-first_name').val()+' '+\$('#registration-last_name').val()\n )"]); ?> <?php echo $form->field($registration_model, 'last_name')->textInput(['maxlength' => true, 'onChange' => "\$('#registration-display_name').val(\n \$('#registration-first_name').val()+' '+\$('#registration-last_name').val()\n )"]); ?> <?php
/** * Finds the RegistrationType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return RegistrationType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = RegistrationType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }