Skip to content

Instantly share code, notes, and snippets.

View jamband's full-sized avatar
👀
web browser

Tomoki Morita jamband

👀
web browser
View GitHub Profile
@jamband
jamband / sample.txt
Last active September 28, 2015 21:39
Yii Framework: Example of user module.
/* user MVC
-----------------------------------------------------------*/
models/
User.php
...
controllers/
UserController.php
...
views/
@jamband
jamband / gist:1526869
Created December 28, 2011 07:02
Yii Framework: Example database migration.
<?php
class m111228_064525_add_user_profile_hoge_table extends CDbMigration
{
protected $options = 'ENGINE=InnoDB DEFAULT CHARSET=utf8';
public function safeUp()
{
// user
$this->createTable('user',
@jamband
jamband / Item.php
Last active September 29, 2015 07:48
Yii Framework: Upload a file using a model 2
<?php
class Item extends ActiveRecord
{
...
/**
* @see CActiveRecord::afterValidate()
*/
protected function afterValidate()
{
if (!$this->hasErrors()) {
@jamband
jamband / FlashBehavior.php
Created January 15, 2012 03:16
Yii Framework: FlashBehavior r3
<?php
/**
* FlashBehavior class file.
*/
class FlashBehavior extends CActiveRecordBehavior
{
/**
* @var string key identifying the flash message
*/
public $key = 'success';
@jamband
jamband / MyDatePicker.php
Last active September 30, 2015 08:38
Yii Framework: How to reduce the amount of the widget code.
<?php
Yii::import('zii.widgets.jui.CJuiDatePicker');
/**
* MyDatePicker class file.
*/
class MyDatePicker extends CJuiDatePicker
{
/**
* @see CJuiDatePicker::language
@jamband
jamband / _form.twig
Last active November 15, 2017 19:07
Yii Framework & Twig: layouts/column1.twig
<div class="form">
{% set form = this.beginWidget('CActiveForm', {
'id': 'hoge-form',
'enableAjaxValidation': false,
}) %}
<p class="note">Fields with <span class="required">*</span> are required.</p>
{{ form.errorSummary(model) }}
@jamband
jamband / main.php
Last active October 1, 2015 06:27
Yii Framework: Example Twig
<?php
return array(
'components' => array(
...
'viewRenderer' => array(
'class' => 'ext.ETwigViewRenderer',
'globals' => array(
'Yii' => 'Yii',
'Captcha' => 'CCaptcha',
),
@jamband
jamband / LinkPager.php
Last active October 1, 2015 07:37
Yii Framework: Example extending CLinkPager class.
<?php
class LinkPager extends CLinkPager
{
/**
* @see CLinkPager::init()
*/
public function init()
{
$this->firstPageLabel = '&laquo;&laquo;';
$this->prevPageLabel = '&laquo;';
@jamband
jamband / Hoge.php
Created March 18, 2012 13:59
Yii Framework: CDbCriteria sample.
<?php
class Hoge extends CActiveRecord
{
...
/**
* 最新のデータを$limit分取得する
*/
public function getRecent($limit=5)
{
$c = new CDbCriteria;
@jamband
jamband / Profile.php
Last active September 25, 2024 00:16
Yii Framework: How to save radioButton, checkBox values.
<?php
class Profile extends CActiveRecord
{
...
/**
* @see Cmodel::rules()
*/
public function rules()
{
return array(