Skip to content

Instantly share code, notes, and snippets.

@jamband
Created December 3, 2011 09:00
Show Gist options
  • Save jamband/1426610 to your computer and use it in GitHub Desktop.
Save jamband/1426610 to your computer and use it in GitHub Desktop.
<?php
/**
* Item class file.
*/
class Item extends CActiveRecord
{
...
/**
* @see CModel::rules()
*/
public function rules()
{
return array(
array('title', 'length', 'max'=>50),
array(
'image',
'file',
'safe' => true,
//'allowEmpty' => true,
'types' => 'jpg,png,gif',
'maxSize' => 1024*1024*1,
'message' => '{attribute}が未選択です',
'on' => 'insert,change',
),
);
}
/**
* @see CModel::behaviors()
*/
public function behaviors()
{
return array(
'ImageUploadBehavior' => array(
'class' => 'application.components.ImageUploadBehavior',
'createThumb' => true,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment