christiansalazar avatar christiansalazar committed 378c02f

preparing example controller

Comments (0)

Files changed (6)

protected/config/main.php

 
 	'modules'=>array(
 		// uncomment the following to enable the Gii tool
-		/*
+		
 		'gii'=>array(
 			'class'=>'system.gii.GiiModule',
-			'password'=>'Enter Your Password Here',
+			'password'=>'123456',
 			// If removed, Gii defaults to localhost only. Edit carefully to taste.
-			'ipFilters'=>array('127.0.0.1','::1'),
+			'ipFilters'=>array('192.168.0.1','::1'),
 		),
-		*/
+		
 	),
 
 	// application components

protected/controllers/ExampleController.php

+<?php
+
+class ExampleController extends Controller
+{
+	public function actions()
+	{
+		return array();
+	}
+	
+	public function actionCreate()
+	{
+		$this->render('create');
+	}
+
+}

protected/models/Example.php

+<?php
+class Example extends CFormModel {
+	public $userid;
+	public $message;
+	
+	public function rules(){
+		array(
+			array('userid','required'),
+			array('message','required'),
+		);
+	}
+}

protected/models/TblUser.php

+<?php
+
+/**
+ * This is the model class for table "tbl_user".
+ *
+ * The followings are the available columns in table 'tbl_user':
+ * @property integer $id
+ * @property string $username
+ * @property string $password
+ * @property string $email
+ */
+class TblUser extends CActiveRecord
+{
+	/**
+	 * Returns the static model of the specified AR class.
+	 * @param string $className active record class name.
+	 * @return TblUser the static model class
+	 */
+	public static function model($className=__CLASS__)
+	{
+		return parent::model($className);
+	}
+	
+	/**
+	 * @return string the associated database table name
+	 */
+	public function tableName()
+	{
+		return 'tbl_user';
+	}
+
+	/**
+	 * @return array validation rules for model attributes.
+	 */
+	public function rules()
+	{
+		// NOTE: you should only define rules for those attributes that
+		// will receive user inputs.
+		return array(
+			array('username, password, email', 'required'),
+			array('username, password, email', 'length', 'max'=>128),
+			// The following rule is used by search().
+			// Please remove those attributes that should not be searched.
+			array('id, username, password, email', 'safe', 'on'=>'search'),
+		);
+	}
+
+	/**
+	 * @return array relational rules.
+	 */
+	public function relations()
+	{
+		// NOTE: you may need to adjust the relation name and the related
+		// class name for the relations automatically generated below.
+		return array(
+		);
+	}
+
+	/**
+	 * @return array customized attribute labels (name=>label)
+	 */
+	public function attributeLabels()
+	{
+		return array(
+			'id' => 'ID',
+			'username' => 'Username',
+			'password' => 'Password',
+			'email' => 'Email',
+		);
+	}
+
+	/**
+	 * Retrieves a list of models based on the current search/filter conditions.
+	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
+	 */
+	public function search()
+	{
+		// Warning: Please modify the following code to remove attributes that
+		// should not be searched.
+
+		$criteria=new CDbCriteria;
+
+		$criteria->compare('id',$this->id);
+		$criteria->compare('username',$this->username,true);
+		$criteria->compare('password',$this->password,true);
+		$criteria->compare('email',$this->email,true);
+
+		return new CActiveDataProvider($this, array(
+			'criteria'=>$criteria,
+		));
+	}
+}

protected/views/example/create.php

+<h1>EYuiSearch Tester</h1>
+
+<p>In this case a simple model needs a user to be selected filtering from your data model, a sqlite in this sample case</p>
+
+

protected/views/site/index.php

 $this->pageTitle=Yii::app()->name;
 ?>
 
-<h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>
+<h1>EYui Example</h1>
 
-<p>Congratulations! You have successfully created your Yii application.</p>
+<p>Dear user, this is an example to test EYui Widgets</p>
+
+<?php echo CHtml::link("Test EYuiSearch",array('example/create'));?>
 
-<p>You may change the content of this page by modifying the following two files:</p>
-<ul>
-	<li>View file: <code><?php echo __FILE__; ?></code></li>
-	<li>Layout file: <code><?php echo $this->getLayoutFile('main'); ?></code></li>
-</ul>
 
-<p>For more details on how to further develop this application, please read
-the <a href="http://www.yiiframework.com/doc/">documentation</a>.
-Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,
-should you have any questions.</p>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.