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 / LoginForm.php
Last active October 2, 2015 21:58
Yii Framework: Custom authentication
<?php
class LoginForm extends CFormModel
{
private $loginLabel;
public $login;
public $password;
public $rememberMe;
/**
@jamband
jamband / Flash.php
Last active October 2, 2015 08:57
Yii Framework: Flash message example.
<?php
class Flash extends CWidget
{
public $keys = array(
'success',
'info',
'warning',
'error',
);
@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(
@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 / 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 / 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 / _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 / 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 / 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 / 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()) {