eorderpositionbehavior Generate and saves values for sorting field.

  1. Requirements
  2. Usage

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.

1 0
Yii Version: 1.1
License: BSD-2-Clause
Category: Database
Developed by: gallyamow
Created on: Oct 5, 2012
Last updated: 11 years ago


show all

Related Extensions