Yii 1.1: eorderpositionbehavior

Generate and saves values for sorting field.

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.


Yii 1.1 or above


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(
            '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.

Be the first person to leave a comment

Please to leave your comment.

Create extension