escelector Reduces annoying need to check if model attributes and relations are empty/null/undefined.

ESelector

  1. Install
  2. Examples
  3. Wow ESelector is so much easier!
  4. Resources

Reduces annoying need to check if model attributes and relations are set.

Install

  1. Place ESelector in your extensions directory

  2. Attach the ESelectorBehavior to your model or base model

public function behaviors()
{
	return array(
		'ESelectorBehavior'=>'ext.ESelector.ESelectorBehavior',
	);
}

Examples

echo $model->selector('title', 'NO TITLE'); 

The above is equivalent to:

if( empty($model->title) ) {
	echo 'NO TITLE';
} else {
	echo $model->title;
}
ESelector also works with relationships
echo $model->selector('contact.fullname', 'No Name');
echo $model->selector('contact.address.city', 'No City');

The above is equivalent to:

if( !is_null($model->contact) && !empty($model->contact->fullname) ) {
	echo $model->contact->fullname)
} else {
	echo 'No Name';
}
if( !is_null($model->contact) && !is_null($model->contact->address) && !empty($model->contact->address->city) ) {
	echo $model->contact->address->city;
} else {
	echo 'No City';
}

Wow ESelector is so much easier!

Resources

3 1
10 followers
327 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: Others
Developed by: evan108108
Created on: May 9, 2013
Last updated: 10 years ago

Downloads

show all

Related Extensions