-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editing sorted item causes it to move to the end of list #28
Comments
What exactly do you edit? And please show code related with editing. |
My
Behavior config is shown in my comment above. This is my tag list view fragment: <?php Pjax::begin(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'class' => SortableColumn::className(),
'gridContainerId' => 'tag-sortable',
'baseUrl' => '/sort/',
'confirmMove' => false,
],
[
'attribute' => 'name',
'format' => 'html',
'value' => function($model) {
return Html::tag('span', $model->name, [
'title' => $model->hint,
]);
},
],
'description_name',
'section_number',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
<?php Pjax::end(); ?> And here is my tag edit form: <div class="tag-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'well_text')->textarea() ?>
<?= $form->field($model, 'description_name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'hint')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'section_number')->dropDownList([
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4'
]); ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ?
Yii::t('modules/catalog/admin', 'add_button') :
Yii::t('modules/catalog/admin', 'update_button'),
['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div> Controller's public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
} So, I can edit tag's |
If you are modifying scope attribute ( |
Value loaded from database is nubmer, but value submited from form is string. You are checking
Other possible solution, on the user end, is to define filters to cast value in model rules(). |
I have a problem. Assume that we have
Tag
model with following fields (some fields aren't listed as they're not needed):ord
- index of this item used for sortingsection_number
- tags are split into several sections, so this field contains section numberAnd here is behavior config:
So, we use our
ord
for sorting andsection_number
as scope.Sorting itself works fine. But if, for example, I will pull item from the end to the beginning of list and then edit it (I can change
section_number
while editing, but I am not doing it actually), item appears at the end.Sorry for my bad English.
The text was updated successfully, but these errors were encountered: