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();
     }
 }
Ejemplo n.º 2
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>
 /**
  * Lists all PositionType models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => PositionType::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }