‏הצגת רשומות עם תוויות php. הצג את כל הרשומות
‏הצגת רשומות עם תוויות php. הצג את כל הרשומות

יום שישי, 12 ביולי 2013

Add simple form in YII

The form declaration

  1: <?php
  2: /* @var $this SiteController */
  3: /* @var $model ContactForm */
  4: /* @var $form CActiveForm */
  5: 
  6: $this->pageTitle=Yii::app()->name . ' - Contact Us';
  7: $this->breadcrumbs=array(
  8:   'Contact',
  9: );
 10: ?>
 11: <h1>Operators</h1>
 12: 
 13: <div class="form">
 14: <?php $form=$this->beginWidget('CActiveForm', array(
 15:   'id'=>'login-form',
 16:   'enableClientValidation'=>true,
 17:   'clientOptions'=>array(
 18:     'validateOnSubmit'=>true,
 19:   ),
 20: )); ?>
 21:   
 22:   
 23:   <div class="row">
 24:     <?php echo $form->labelEx($model,'Search for:'); ?>
 25:     <?php echo $form->textField($model,'Name'); ?>
 26:     
 27:   </div>
 28:   
 29:   <div class="row buttons">
 30:     <?php echo CHtml::submitButton('Start Search'); ?>
 31:   </div>
 32: 
 33: <?php $this->endWidget(); ?>
 34: </div><!-- form -->
 35: 

The modal


  1: <?php
  2: class OperatorModel extends CFormModel
  3: {
  4:   function __construct() {
  5:        parent::__construct();     
  6:    }
  7:    
  8:    public $Name;
  9: }
 10: ?>
 11: 

The result
Capture50

יום חמישי, 27 ביוני 2013

render a simple view in yii

Changes in the SiteController.php:
Add

  1: 
  2:   public function actionOperators()
  3:   {
  4:     $emodel=new OperatorModel;
  5:     
  6:     $model->Name = "zvika";
  7:     
  8:     // display the login form
  9:     $this->render('pages/Operators',array('model'=>$model));
 10:   }

The simple operator view:


  1: <?php
  2: /* @var $this SiteController */
  3: 
  4: $this->pageTitle=Yii::app()->name . ' - Operators';
  5: $this->breadcrumbs=array(
  6:   'Operators',
  7: );
  8: ?>
  9: <h1>Operators</h1>
 10: 
 11:  <?php echo $model->Name; ?>
 12:  
 13:  <?php echo CHtml::activeLabel($model,'Name'); ?>
 14:  

The operator model


  1: <?php
  2: class OperatorModel extends CFormModel
  3: {
  4:     public $Name;
  5: }
  6: ?>

Add the menu item to the main.php


  1: <div id="mainmenu">
  2:     <?php $this->widget('zii.widgets.CMenu',array(
  3:       'items'=>array(
  4:         array('label'=>'Home', 'url'=>array('/site/index')),
  5:         array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
  6:           array('label'=>'Operators', 'url'=>array('/site/Operators')),
  7:         array('label'=>'Contact', 'url'=>array('/site/contact')),
  8:         array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
  9:         array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
 10:       ),
 11:     )); ?>

The result :
Capture42

יום חמישי, 6 ביוני 2013

Generate operator portal Skelton

 

Generate Skelton in yii using the yiic command :

C:\Program Files\Zend\Apache2\htdocs\yii\framework>yiic webapp ../WebRoot/Operat
orsPortal
Create a Web application under 'C:\Program Files\Zend\Apache2\htdocs\yii\WebRoot
\OperatorsPortal'? (yes|no) [no]:y

change the time zone in the controller elsewhere an exception will be thrown :

  1: <?php /* @var $this Controller */ ?>
  2: <?php date_default_timezone_set('America/Los_Angeles');?>

Test the crated web site :http://localhost/yii/WebRoot/OperatorsPortal/index.php


Capture26 


Resources:
http://php.net/manual/en/function.date-default-timezone-set.php
YII documentation

simple yii

After unpacking the yii-1.1.13.e9e4a0.zip file into the C:\Program Files\Zend\Apache2\htdocs directory I had notice the hello world sample in the demos directory:
C:\Program Files\Zend\Apache2\htdocs\yii\demos\helloworld
I lunch it using :
http://localhost/yii/demos/helloworld/index.php
And Walla :
Capture24
The code is very trivial:
The index.php file that inits the Yii bootstrap
and create and run the web application

  1: <?php
  2: 
  3: // include Yii bootstrap file
  4: require_once(dirname(__FILE__).'/../../framework/yii.php');
  5: 
  6: // create a Web application instance and run
  7: Yii::createWebApplication()->run();

The controller :SiteController.php that override the default actionIndex method


  1: <?php
  2: 
  3: /**
  4:  * SiteController is the default controller to handle user requests.
  5:  */
  6: class SiteController extends CController
  7: {
  8: 	/**
  9: 	 * Index action is the default action in a controller.
 10: 	 */
 11: 	public function actionIndex()
 12: 	{
 13: 		echo 'Hello World';
 14: 	}
 15: }