The behavior allows to a model generate and save sorting field values.
For example you have to sort the records in the table by a particular field. You can use this extension to fill the value of this field when saving model. Values are generated in the form of 10, 20, 30, 40, etc.
You can add a constraint on any fields available in the model. Thus for example, if there is a field "category_id", then adding it to "conditionFields" can generate values from 10, 20, 30, etc for this category.
Requirements ¶
Yii 1.1 or above
Usage ¶
Just add the behavior to your behaviors list in your model (after placing the behavior in your app.extension folder).
public function behaviors()
{
return array(
'EOrderPosition'=>array(
'class'=>'ext.EOrderPositionBehavior',
'positionField'=>'order_position', // sorting field name
'conditionFields'=>array('category_id'), // additional conditions fields
)
);
}
When the records will has added, 'order_position' will has values like 10, 20, 30 etc.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.