/**
  * @return \yii\db\ActiveQuery
  */
 public function getAccountabilities()
 {
     return $this->hasMany(Accountability::className(), ['id' => 'accountability_id'])->viaTable(PositionTypeAccountability::tableName(), ['position_type_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAccountability()
 {
     return $this->hasOne(Accountability::className(), ['id' => 'accountability_id']);
 }
 /**
  * Finds the Accountability model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Accountability the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Accountability::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #4
0
/* @var $model app\models\PositionType */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="position-type-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
$list = ArrayHelper::map(Accountability::find()->all(), 'id', 'name');
$checked = ArrayHelper::getColumn($model->accountabilities, 'id');
echo Html::checkboxList('PositionType[accountability_list]', $checked, $list);
?>

    <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();
?>

</div>