/** * Finds the TicketGroup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TicketGroup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TicketGroup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getTicketGroups() { return $this->hasMany(TicketGroup::className(), ['event_id' => 'id']); }
use yii\widgets\ActiveForm; use app\models\TicketGroup; use app\models\TicketType; /* @var $this yii\web\View */ /* @var $model app\models\Ticket */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="ticket-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'group_id')->dropDownList(TicketGroup::getList()); ?> <?php echo $form->field($model, 'type_id')->dropDownList(TicketType::getList()); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'ticket_price')->textInput(['maxlength' => true]); ?> <?php
public function getGroup() { return $this->hasOne(TicketGroup::className(), ['id' => 'group_id']); }