xdetailview This extension modified CDetailView to support multiple label/value pairs per line.

  1. Update
  2. Requirements
  3. Usage
  4. Usage - Scenario Two - multiple widgets - depreciated
  5. Usage - Version 2.0
  6. Resources

Yii default CDetailView display one label/value pair per line. With this widget you could display multiple label/value pairs per line. Also if you use null as your attribute item, you can nicely layout your detail view.

Update

  • version 0.0 - start from CDetailView
  • version 1.0 - supports multiple columns label/value pair
  • version 2.0 - supports nested {attributes}

Requirements

Tested under Yii 1.1.10

Usage

in your /views/<model>/view.php file, replace CDetaiView with XDetailView

newly added parameter : ItemColumns specify number of label/value pair per line, null in attributes array for purpose of adjusting layout

<?php $this->widget('application.components.widgets.XDetailView', array(
	'data' => $model,
	'ItemColumns' => 2,
	'attributes' => array(
			'account',
			'company',
			'address1',
			'address2',
			'city',
			'province',
			null,
			array(
				'label'=>'Created:',
				'type'=>'raw',
				'value'=>$model->create_time,
			),
			null,
			array(
				'label'=>'Updated:',
				'type'=>'raw',
				'value'=>$model->update_time,
			),
	),
)); ?>

Usage - Scenario Two - multiple widgets - depreciated

in case you have a field with long text or an image, you may have a little bit trouble to layout them nicely use nether CDetailView or XDetailView, however you can simply do the following trick:

*note: initially I thought about to modified original code to handle this case, then I figure it's too much hacking, so I come up with this simple trick

<?php $this->widget('application.components.widgets.XDetailView', array(
	'data' => $model,
	'ItemColumns' => 2,
	'attributes' => array(
			'account',
			'company',
			'city',
			'province',
	),
)); ?>

//2nd widget goes here for the same model
<?php $this->widget('application.components.widgets.XDetailView', array(
	'data' => $model,
	'ItemColumns' => 1, // one pair per line here
	'attributes' => array(
			'long_text_field',
	),
)); ?>

//if you have model with hundreds of fields, more XDetailView widgets with different *ItemColumns* value from sample model could goes on & on here.

Usage - Version 2.0

supports nested {attribues}.

<?php $this->widget('application.components.widgets.XDetailView', array(
	'data' => $model,
	'attributes' => array(
		'group1'=>array(
			'attributes' => array(
					'account',
					'company',
					'city',
					'province',
			),
		),
		'group2'=>array(
			'ItemColumns' => 2,
			'attributes' => array(
					'account',
					'company',
					'city',
					'province',
			),
		),
		'group3'=>array(
			'ItemColumns' => 1, // one pair per line here
			'attributes' => array(
				'long_text_field',
			),
		),
	),
)); ?>

Resources

CDetailView

2 0
11 followers
902 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: rootbear
Created on: Mar 29, 2012
Last updated: 5 years ago

Downloads

show all