public function up()
 {
     $lists = [0 => [1, 2, 3, 6, 7, 8, 9, 10, 11], 1 => [1, 2, 3, 4, 5, 6, 7], 2 => [2, 4, 6, 8, 10, 11], 3 => [6, 4, 3, 2]];
     $pos = 0;
     foreach (PositionType::find()->all() as $positionType) {
         $positionType->accountability_list = $lists[++$pos % 4];
         $positionType->save();
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getType()
 {
     return $this->hasOne(PositionType::className(), ['id' => 'type_id']);
 }
Example #3
0
<div class="position-form">

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

    <?php 
echo $form->field($model, 'name')->input('text');
?>
    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(PositionType::find()->all(), 'id', 'name'));
?>



    <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>
 /**
  * Finds the PositionType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PositionType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PositionType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }