public function validate_dname($attribute) { $d = DisciplineList::find()->where(['discipline_name' => $attribute]); if (empty($d)) { $this->addError($attribute, 'Така дисципліна вже присутня'); } }
/** * Finds the DisciplineList model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return DisciplineList the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DisciplineList::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
$housing = Housing::findOne(['housing_id' => $cl['id_housing']]); $classroomsArray[$cl['classrooms_id']] = $cl['classrooms_number'] . ' - ' . $housing['name']; } $d = Discipline::findAll(['id_group' => $id_group]); if (empty($d)) { $d = Discipline::findAll(['id_group' => $students_in_group[0]['parent_group']]); } if (empty($d)) { echo '<div class="alert alert-danger" role="alert">Для даної групи немає дисциплін!</div>'; exit; } foreach ($d as $dd) { //$disciplines = Discipline::findAll(['discipline_distribution_id' => $dd['id_discipline']]); $disciplines = Discipline::findAll(['id_discipline' => $dd['id_discipline']]); foreach ($disciplines as $disc) { $disc_name = DisciplineList::findOne(['discipline_id' => $disc['id_discipline']]); $disc_type = LessonsType::findOne(['id' => $disc['id_lessons_type']]); $da[$disc['discipline_distribution_id']] = $disc_name['discipline_name'] . " - " . $disc_type['lesson_type_name']; } } asort($da); foreach ($da as $x => $x_value) { $discipline_array[$x] = $x_value; } ?> <div class="lessons-form"> <?php $form = ActiveForm::begin(); ?>
<?php use yii\helpers\Html; use app\module\handbook\models\DisciplineList; /* @var $this yii\web\View */ /* @var $model app\module\handbook\models\Discipline */ $d_name = DisciplineList::findOne([$model->id_discipline]); $this->title = 'Оновити інформацію про дисципліну: ' . ' ' . $d_name['discipline_name']; $this->params['breadcrumbs'][] = ['label' => 'Дисципліни', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $d_name['discipline_name'], 'url' => ['view', 'id' => $model->discipline_distribution_id]]; $this->params['breadcrumbs'][] = 'Оновити'; ?> <div class="discipline-update"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo $this->render('_form', ['model' => $model]); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getDisciplineName() { return $this->hasOne(DisciplineList::className(), ['discipline_id' => 'id_discipline']); }
foreach ($all_faculty as $af) { $tmp_cathedra = Cathedra::find()->where(['id_faculty' => $af['faculty_id']])->orderBy('cathedra_name ASC')->all(); foreach ($tmp_cathedra as $tc) { $all_cathedra[$tc['cathedra_id']] = $tc['cathedra_name'] . " / " . $af['faculty_name']; } } ?> <div class="discipline-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'id_discipline')->widget(Select2::classname(), ['data' => ArrayHelper::map(DisciplineList::find()->orderBy('discipline_name ASC')->all(), 'discipline_id', 'discipline_name'), 'language' => 'uk', 'pluginOptions' => ['allowClear' => true]])->label('Дисципліна'); ?> <?php echo $form->field($model, 'id_cathedra')->widget(Select2::classname(), ['data' => $all_cathedra, 'language' => 'uk', 'pluginOptions' => ['allowClear' => true]])->label('Кафедра'); ?> <?php echo $form->field($model, 'id_lessons_type')->widget(Select2::classname(), ['data' => ArrayHelper::map(LessonsType::find()->all(), 'id', 'lesson_type_name'), 'language' => 'uk', 'pluginOptions' => ['allowClear' => true]])->label('Тип заняття'); ?> <?php echo Html::label("Групи"); echo Select2::widget(['model' => $model, 'attribute' => 'id_group', 'language' => 'ru', 'data' => ArrayHelper::map(Groups::find()->all(), 'group_id', 'main_group_name')]); ?>
function getDisciplineName($id_discipline) { $disc_info = Discipline::findOne(['discipline_distribution_id' => $id_discipline]); $discipline_name = DisciplineList::findOne(['discipline_id' => $disc_info['id_discipline']]); return $discipline_name['discipline_name']; }