Professional Documents
Culture Documents
Zend_View (Phn 2)
Trong Zend_View phn 2 ny chng ta s nghin cu nhng phng thc to ra i tng trong form. Cc i tng ny c gi l Zend_View_Helper. Cc i tng thuc loi Zend_View_Helper thng c s dng ngoi View ca m hnh MVC. (Ch : Tt c v d y thc hin trong phn View ca ng dng) 1. Ly tn Server hin thi (Zend_View_Helper_ServerUrl) V d:
<?php echo $this->serverUrl(); ?>
2. To ng dn url (Zend_View_Helper_Url)
$this->url ($urlOptions, $name , $reset = false, $encode = true) $urlOptions: Mng thng s truyn vo to link $name: Mt i tng cu hnh ca Zend_Controller_Router_Route
3. To button (Zend_View_Helper_FormButton)
$this->formButton($name, $value = null, $attribs = null); $name: tn ca i tng $value: gi tr ca i tng $attribs: cc thuc tnh ca i tng nh size, color, background (array)
V d:
<?php echo $this->formButton('submit', 'Save Now', array('style'=>'border: #666666 1px solid')); ?> <br/><br/>
4. To CheckBox (Zend_View_Helper_FormCheckbox)
$this->formCheckbox($name, $value = null, $attribs = null); $name: tn ca i tng $value: gi tr ca i tng $attribs: cc thuc tnh ca i tng nh size, color, background (array)
V d:
<?
Email: vukhanh2212@gmail.com
echo $this->formCheckbox ( 'myCheckbox_1', 'Yes', array ('checked' => 'checked' ) ); echo $this->formCheckbox ( 'myCheckbox_2', 'No', null ); ?> <br/><br/>
V d:
<? $arrError = array ('Happy 1', 'Happy 2' ); $options = array ('style' => ' color:#FF0000; font-size:15px' ); //$this->formErrors($errors, array $options = null); echo $this->formErrors ( $arrError, $options ); ?> <br/><br/>
6. To file (Zend_View_Helper_FormFile)
$this->formFile($name, $value = null, $attribs = null); $name: tn ca i tng $value: gi tr ca i tng $attribs: cc thuc tnh ca i tng nh size, color, background (array)
V d:
<?=$this->formFile ( 'myFile', '', array ('size' => '40' ) );?> <br/><br/>
7. To hidden (Zend_View_Helper_FormHidden)
$this->formHidden($name, $value = null, array $attribs = null); $name: tn ca i tng $value: gi tr ca i tng $attribs: cc thuc tnh ca i tng nh size, color, background (array)
V d:
<?=$this->formHidden ( 'hidden', 'abc' );?> <br/><br/>
8. To Image (Zend_View_Helper_FormImage)
$this->formImage($name, $value = null, $attribs = null); $name: tn ca i tng $value: gi tr ca i tng $attribs: cc thuc tnh ca i tng nh size, color, background (array)
V d:
<?=$this->formImage ( 'myImage', 'abcImage', array ('src' => 'images/img001.jpg' ) );?> <br/><br/>
9. To Password (Zend_View_Helper_FormPassword)
$this->formPassword($name, $value = null, $attribs = null); Guide: Phm V Khnh 2 Email: vukhanh2212@gmail.com
Gio trnh: Zend Framework Zend_View (phn 2) $name: tn ca i tng $value: gi tr ca i tng $attribs: cc thuc tnh ca i tng nh size, color, background (array)
V d:
<?=$this->formPassword('myPassword','',array('size'=>'30'));?> <br/><br/>
V d:
<?php $options = array ('1' => 'Happy', '2' => 'Birthday', '3' => 'To', '4' => 'You' ); echo $this->formRadio ( 'myRadio_1', 1, null, $options, ' ' ); echo '<br>' . $this->formRadio ( 'myRadio_2', 3, null, $options, ' ' ); ?> <br/><br/>
V d:
<?php echo $this->formReset ( 'myReset', 'Reset', array ('style' => 'border: #666666 1px solid' ) ); ?> <br/><br/>
V d:
<?php $options = array ('1' => 'Happy', '2' => 'Birthday','3' => 'To','4' => 'You' ); echo $this->formSelect ( 'mySelect', 1, array ('style' => 'width: 150px' ), $options, null ); ?> <br/><br/>
Gio trnh: Zend Framework Zend_View (phn 2) $this->formSubmit($name, $value = null, $attribs = null); $name: tn ca i tng $value: gi tr ca i tng $attribs: cc thuc tnh ca i tng nh size, color, background (array)
V d:
<?php Echo $this->formSubmit('mySubmit','Save Now', array('style'=>'border: #666666 1px solid')); ?> <br/><br/>
V d:
<?php echo $this->formText('myText', 'I love ZF', array('style'=>' color:#FF0000; fontsize:15px')); ?> <br/><br/>
V d:
<?php echo $this->formTextarea('myTextArea', 'I love ZF', array('cols'=>'60','rows'=>'8')); ?> <br><br>
V d:
<?php $options = array('1'=> 'admin','2'=>'mod','3'=>'user'); echo $this->formMultiCheckbox('abc',array('1','3'),array('width'=>'200px'),$options); ?>
$this->partial ([string $name = null], [string|array $module = null], [array $model = null]) string $name: Tn ca script (.php, .phtml) string|array $module: gi tr c a nhn t view truyn vo array $model: gi tr c a nhn t view truyn v
scripts/partial.phtml
<ul> <li>From: <?php echo $this->escape($this->from) ?></li> <li>Subject: <?php echo $this->escape($this->subject) ?></li> </ul>
index3.phtml
<h1> index3.phtml</h1> <?php echo $this->partial('partial.phtml', array( 'from' => 'Team Framework', 'subject' => 'view partials')); ?>
scripts\partialLoop.phtml
<?php // partialLoop.phtml ?> <dt><?php echo $this->key ?></dt> <dd><?php echo $this->value ?></dd>
\view\index4.phtml
<h1> index4.phtml</h1> <dl> <?php $model = array( array('key' => 'Mammal', 'value' => 'Camel'), array('key' => 'Bird', 'value' => 'Penguin'), array('key' => 'Reptile', 'value' => 'Asp'), array('key' => 'Fish', 'value' => 'Flounder'), ); ?> <?php echo $this->partialLoop('partialLoop.phtml', $model) ?> </dl>
V d:
<?php echo $this->action('index3','index','default');?>
Email: vukhanh2212@gmail.com