ztabularinputmanager This class will help anyone that have to collect a tabular input

This class is a master class for a Tabular input manager.

It has been tought to be used in scenarios where you have a one-to-many relationship.

The interface should present an interface for collect the data of the one, and zero, one or many rows for collect the many.

In the hypothesis that we have to insert a ClassRoom with many Students, we will create a StudentManager by extending Tabular input manager:


class StudentManager extends TabularInputManager

	protected $class='Student';
	public function getItems()
		if (is_array($this->_items))
			return ($this->_items);
			return array(
				'n0'=>new Student,

	public function deleteOldItems($model, $itemsPk)
		$criteria=new CDbCriteria;
		$criteria->addNotInCondition('id', $itemsPk);
		$criteria->addCondition("class_id= {$model->primaryKey}");


	public static function load($model)
		$return= new StudentManager;
		foreach ($model->students as $item)
		return $return;
	public function setUnsafeAttribute($item, $model)



In this class we implement all methods needed for manage the primary keys of the students, for load the student of a class, for delete students.

The typical controller code for use this manager is:

	 * Update a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	public function actionCreate()
		$model=new ClassRoom;
		$studentManager=new studentManager();

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

19 0
2 920 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: zaccaria
Created on: Oct 18, 2010
Last updated: 5 years ago


show all

Related Extensions