you have to make some changes in this code according to you need but it wil help you alot....
1: View:
<?php echo $this->food; ?>
<?php echo $this->cab; ?>
2:Controller:
public function indexAction(){
$ReimbursermentFood=new Form_Webchutney( array('selectForm' => '__FOOD_REIMBURSEMENT'));
$ReimbursermentCab=new Form_Webchutney( array('selectForm' => '__CAB_REIMBURSEMENT'));
$Employeearray=array();
$Employeearray['AccountManager']='Account Manager';
$Employeearray['aktel']='aktel';
$Employeearray['saurabh.patel']='saurabh patel';
$ReimbursermentFood->setAction('/user/reimbursement/food');
$ReimbursermentFood->setAttrib("id","foodForm");
$AccountManager = $ReimbursermentFood->getElement('AccountManager');
$AccountManager->setLabel('')
->addMultiOptions($Employeearray);
#$AccountManager->setValue("Aditya Kumar");
$AccountManager->setAttrib('readonly', 'readonly');
$this->view->Food=$ReimbursermentFood;
$ReimbursermentCab->setAction('/user/reimbursement/cab');
$ReimbursermentCab->setAttrib("id","cabForm");
$AccountManager = $ReimbursermentCab->getElement('AccountManager');
#$AccountManager->setValue("Aditya Kumar");
$AccountManager->setLabel('')
->addMultiOptions($Employeearray);
$AccountManager->setAttrib('readonly', 'readonly');
#$ReimbursermentCab->removeElement("Amount");
$this->view->Cab=$ReimbursermentCab;
}
3:Form:
_________________________________________
<?php
class Form_Aktel extends Zend_Form {
/* @access Public
* @var object
*/
/* @access Public
* @var object
*/
public $REInput;
public $REButton;
protected $selectForm = '';
public function setselectForm($param) {
$this->selectForm = $param;
}
private function decorator(){
$this->REInput= New Form_Decorator_ReInput();
$this->REButton= New Form_Decorator_ReButton();
$this->RESETButton= New Form_Decorator_ResetButton();
}
public function init() {
$this->decorator();
switch ($this->selectForm)
{
CASE '__FOOD_REIMBURSEMENT':
$this->foodForm();
break;
CASE '__CAB_REIMBURSEMENT':
$this->cabForm();
break;
}
}
private function foodForm() {
$this->setMethod('post') ;
// date
$accountDate = $this->createElement('text', 'date');
$accountDate->setValue('Date');
$accountDate->setRequired(TRUE);
$accountDate->setAttrib('size', 30);
$accountDate->setDecorators(array($this->REInput)) ;
$accountDate->setAttrib('id','food_datepicker');
$accountDate->setAttrib('Class','date');
// name
$accountName = $this->createElement('text', 'Name');
$accountName->setValue('Name');
$accountName->setRequired(TRUE);
$accountName->setAttrib('size', 30);
$accountName->setDecorators(array($this->REInput)) ;
$accountName->setAttrib('id','food_Name');
$accountName->setAttrib('Class','txtfld');
// Project
$accountProject = $this->createElement('text', 'Project');
$accountProject->setValue('Project');
$accountProject->setRequired(TRUE);
$accountProject->setAttrib('size', 30);
$accountProject->setDecorators(array($this->REInput)) ;
$accountProject->setAttrib('id','food_Project');
$accountProject->setAttrib('Class','txtfld');
// AccountManager
/*
$accountAccountManager = $this->createElement('text', 'AccountManager');
$accountAccountManager->setValue('Account Manager');
$accountAccountManager->setRequired(TRUE);
$accountAccountManager->setAttrib('size', 30);
$accountAccountManager->setDecorators(array($this->REInput)) ;
$accountAccountManager->setAttrib('id','food_AccountManager');
$accountAccountManager->setAttrib('Class','txtfld');
*/
$accountAccountManager = new Zend_Form_Element_Select('AccountManager');
// Punch_time
$accountPunch_time =$this->createElement('text', 'Punch_time');
$accountPunch_time->setValue('Punch Time');
$accountPunch_time->setRequired(TRUE);
$accountPunch_time->setAttrib('size', 30);
$accountPunch_time->setDecorators(array($this->REInput)) ;
$accountPunch_time->setAttrib('id','food_Punch_time');
$accountPunch_time->setAttrib('Class','time');
// Order_time
$accountOrder_time =$this->createElement('text', 'Order_time');
$accountOrder_time->setValue('Order Time');
$accountOrder_time->setRequired(TRUE);
$accountOrder_time->setAttrib('size', 30);
$accountOrder_time->setDecorators(array($this->REInput)) ;
$accountOrder_time->setAttrib('id','food_Order_time');
$accountOrder_time->setAttrib('Class','time');
// Amount
$accountAmount =$this->createElement('text', 'Amount');
$accountAmount->setValue('Billed Amount');
$accountAmount->setRequired(TRUE);
$accountAmount->setAttrib('size', 30);
$accountAmount->setDecorators(array($this->REInput)) ;
$accountAmount->setAttrib('id','food_Amount');
$accountAmount->setAttrib('Class','txtfld');
//submit
$accountSubmit =new Zend_Form_Element_Submit('Submit');
$accountSubmit->setDecorators(array($this->REButton)) ;
//submit
$accountButtom =new Zend_Form_Element_Button('Reset');
$accountButtom->setDecorators(array($this->RESETButton));
$accountFrom = $this->createElement('hidden', 'from')
->setValue(rand(1, 9999999999));
// CSR
$accountcsr = $this->createElement('hash', 'no_csr', array( 'salt' => 'unique'));
$this->addElements(array($accountDate, $accountName ,$accountProject, $accountAccountManager, $accountPunch_time, $accountOrder_time , $accountAmount , $accountSubmit , $accountButtom , $accountFrom,$accountcsr));
$this->setDecorators(array( 'FormElements','Form'));
}
private function cabForm() {
$this->setMethod('post') ;
// date
$accountDate = $this->createElement('text', 'date');
$accountDate->setValue('Date');
$accountDate->setRequired(TRUE);
$accountDate->setAttrib('size', 30);
$accountDate->setDecorators(array($this->REInput)) ;
$accountDate->setAttrib('id','cab_datepicker');
$accountDate->setAttrib('Class','date');
// name
$accountName = $this->createElement('text', 'Name');
$accountName->setValue('Name');
$accountName->setRequired(TRUE);
$accountName->setAttrib('size', 30);
$accountName->setDecorators(array($this->REInput)) ;
$accountName->setAttrib('id','cab_Name');
$accountName->setAttrib('Class','txtfld');
// Project
$accountProject = $this->createElement('text', 'Project');
$accountProject->setValue('Project');
$accountProject->setRequired(TRUE);
$accountProject->setAttrib('size', 30);
$accountProject->setDecorators(array($this->REInput)) ;
$accountProject->setAttrib('id','cab_Project');
$accountProject->setAttrib('Class','txtfld');
// AccountManager
/* $accountAccountManager = $this->createElement('text', 'AccountManager');
$accountAccountManager->setValue('Account Manager');
$accountAccountManager->setRequired(TRUE);
$accountAccountManager->setAttrib('size', 30);
$accountAccountManager->setDecorators(array($this->REInput)) ;
$accountAccountManager->setAttrib('id','cab_AccountManager');
$accountAccountManager->setAttrib('Class','txtfld'); */
$accountAccountManager = new Zend_Form_Element_Select('AccountManager');
//Pick_Up_Area for cab
$accountPick_Up_Area =$this->createElement('text', 'Pick_Up_Area');
$accountPick_Up_Area->setValue('Pickup Area');
$accountPick_Up_Area->setRequired(TRUE);
$accountPick_Up_Area->setAttrib('size', 30);
$accountPick_Up_Area->setDecorators(array($this->REInput)) ;
$accountPick_Up_Area->setAttrib('id','cab_Pick_Up_Area');
$accountPick_Up_Area->setAttrib('Class','picfrom');
//Drop_Area for cab
$accountDrop_Area =$this->createElement('text', 'Drop_Area');
$accountDrop_Area->setValue('Drop Area');
$accountDrop_Area->setRequired(TRUE);
$accountDrop_Area->setAttrib('size', 30);
$accountDrop_Area->setDecorators(array($this->REInput)) ;
$accountDrop_Area->setAttrib('id','cab_Drop_Area');
$accountDrop_Area->setAttrib('Class','picto');
}
}
private function forgotPasswordForm() {
$this->setMethod('post')
->setAttrib('id', 'forgotPassword')
->setAttrib('name', 'forgotPassword');
$emailInput= $this->createElement('text', 'Email');
$emailInput->setLabel('Enter your EmailID');
$emailInput->setRequired(TRUE);
$emailInput->setAttrib('size', 30);
$emailInput->setDecorators(array($this->Input)) ;
$emailInput->addValidator('NotEmpty', true, array('messages' => 'Error_Account_Missing_Email_Field' ));
//submit
$accountSubmit =new Zend_Form_Element_Submit('Submit');
$accountSubmit->setLabel('Submit');
$accountSubmit->setValue('Submit');
$accountSubmit->setDecorators(array($this->Button)) ;
$accountFrom = $this->createElement('hidden', 'from')
->setValue(rand(1, 9999999999));
// CSR
$accountcsr = $this->createElement('hash', 'no_csr', array( 'salt' => 'unique'));
$this->addElements(array($accountUsername,$accountPassword,$accountSubmit,$accountFrom,$accountcsr));
$this->setDecorators(array( 'FormElements','Form'));
}
}
4:Decorator:
_________________________________________________________________________________-
<?php
class Form_Decorator_ReSelect extends Zend_Form_Decorator_Abstract
{
protected $_format = '<div></div>';
public function render($content)
{
$element = $this->getElement();
$name = htmlentities($element->getFullyQualifiedName());
$label = htmlentities($element->getLabel());
$id = htmlentities($element->getId());
$value = htmlentities($element->getValue());
$markup = sprintf($this->_format,$id, $name, $value);
return $markup;
}
}
__________________________________________________________________________________________
<?php
class Form_Decorator_ReInput extends Zend_Form_Decorator_Abstract
{
protected $_format ='<div class="frmbx">
<div class="txtbxlft"></div>
<div class="txtbxmid"><input type="text" class="%s" id="%s" name="%s" value="%s" /><span>*</span></div>
<div class="txtbxrht"></div>
</div>';
public function render($content)
{
$element = $this->getElement();
$Class=htmlentities($element->getAttrib("Class"));
$id = htmlentities($element->getAttrib("id"));
$name = htmlentities($element->getFullyQualifiedName());
$value = htmlentities($element->getValue());
$markup = sprintf($this->_format, $Class, $id, $name, $value);
return $markup;
}
}
____________________________________________________________________________________________
<?php
class Form_Decorator_ReButton extends Zend_Form_Decorator_Abstract
{
protected $_format ='<div class="frmbxsubmit">
<input id="%s" name="%s" type="submit" value="" class="submitbtn">
</div>';
public function render($content)
{
$element = $this->getElement();
$name = htmlentities($element->getFullyQualifiedName());
$label = htmlentities($element->getLabel());
$id = htmlentities($element->getId());
$value = htmlentities($element->getValue());
$markup = sprintf($this->_format,$id, $name);
return $markup;
}
}
1: View:
<?php echo $this->food; ?>
<?php echo $this->cab; ?>
2:Controller:
public function indexAction(){
$ReimbursermentFood=new Form_Webchutney( array('selectForm' => '__FOOD_REIMBURSEMENT'));
$ReimbursermentCab=new Form_Webchutney( array('selectForm' => '__CAB_REIMBURSEMENT'));
$Employeearray=array();
$Employeearray['AccountManager']='Account Manager';
$Employeearray['aktel']='aktel';
$Employeearray['saurabh.patel']='saurabh patel';
$ReimbursermentFood->setAction('/user/reimbursement/food');
$ReimbursermentFood->setAttrib("id","foodForm");
$AccountManager = $ReimbursermentFood->getElement('AccountManager');
$AccountManager->setLabel('')
->addMultiOptions($Employeearray);
#$AccountManager->setValue("Aditya Kumar");
$AccountManager->setAttrib('readonly', 'readonly');
$this->view->Food=$ReimbursermentFood;
$ReimbursermentCab->setAction('/user/reimbursement/cab');
$ReimbursermentCab->setAttrib("id","cabForm");
$AccountManager = $ReimbursermentCab->getElement('AccountManager');
#$AccountManager->setValue("Aditya Kumar");
$AccountManager->setLabel('')
->addMultiOptions($Employeearray);
$AccountManager->setAttrib('readonly', 'readonly');
#$ReimbursermentCab->removeElement("Amount");
$this->view->Cab=$ReimbursermentCab;
}
3:Form:
_________________________________________
<?php
class Form_Aktel extends Zend_Form {
/* @access Public
* @var object
*/
/* @access Public
* @var object
*/
public $REInput;
public $REButton;
protected $selectForm = '';
public function setselectForm($param) {
$this->selectForm = $param;
}
private function decorator(){
$this->REInput= New Form_Decorator_ReInput();
$this->REButton= New Form_Decorator_ReButton();
$this->RESETButton= New Form_Decorator_ResetButton();
}
public function init() {
$this->decorator();
switch ($this->selectForm)
{
CASE '__FOOD_REIMBURSEMENT':
$this->foodForm();
break;
CASE '__CAB_REIMBURSEMENT':
$this->cabForm();
break;
}
}
private function foodForm() {
$this->setMethod('post') ;
// date
$accountDate = $this->createElement('text', 'date');
$accountDate->setValue('Date');
$accountDate->setRequired(TRUE);
$accountDate->setAttrib('size', 30);
$accountDate->setDecorators(array($this->REInput)) ;
$accountDate->setAttrib('id','food_datepicker');
$accountDate->setAttrib('Class','date');
// name
$accountName = $this->createElement('text', 'Name');
$accountName->setValue('Name');
$accountName->setRequired(TRUE);
$accountName->setAttrib('size', 30);
$accountName->setDecorators(array($this->REInput)) ;
$accountName->setAttrib('id','food_Name');
$accountName->setAttrib('Class','txtfld');
// Project
$accountProject = $this->createElement('text', 'Project');
$accountProject->setValue('Project');
$accountProject->setRequired(TRUE);
$accountProject->setAttrib('size', 30);
$accountProject->setDecorators(array($this->REInput)) ;
$accountProject->setAttrib('id','food_Project');
$accountProject->setAttrib('Class','txtfld');
// AccountManager
/*
$accountAccountManager = $this->createElement('text', 'AccountManager');
$accountAccountManager->setValue('Account Manager');
$accountAccountManager->setRequired(TRUE);
$accountAccountManager->setAttrib('size', 30);
$accountAccountManager->setDecorators(array($this->REInput)) ;
$accountAccountManager->setAttrib('id','food_AccountManager');
$accountAccountManager->setAttrib('Class','txtfld');
*/
$accountAccountManager = new Zend_Form_Element_Select('AccountManager');
// Punch_time
$accountPunch_time =$this->createElement('text', 'Punch_time');
$accountPunch_time->setValue('Punch Time');
$accountPunch_time->setRequired(TRUE);
$accountPunch_time->setAttrib('size', 30);
$accountPunch_time->setDecorators(array($this->REInput)) ;
$accountPunch_time->setAttrib('id','food_Punch_time');
$accountPunch_time->setAttrib('Class','time');
// Order_time
$accountOrder_time =$this->createElement('text', 'Order_time');
$accountOrder_time->setValue('Order Time');
$accountOrder_time->setRequired(TRUE);
$accountOrder_time->setAttrib('size', 30);
$accountOrder_time->setDecorators(array($this->REInput)) ;
$accountOrder_time->setAttrib('id','food_Order_time');
$accountOrder_time->setAttrib('Class','time');
// Amount
$accountAmount =$this->createElement('text', 'Amount');
$accountAmount->setValue('Billed Amount');
$accountAmount->setRequired(TRUE);
$accountAmount->setAttrib('size', 30);
$accountAmount->setDecorators(array($this->REInput)) ;
$accountAmount->setAttrib('id','food_Amount');
$accountAmount->setAttrib('Class','txtfld');
//submit
$accountSubmit =new Zend_Form_Element_Submit('Submit');
$accountSubmit->setDecorators(array($this->REButton)) ;
//submit
$accountButtom =new Zend_Form_Element_Button('Reset');
$accountButtom->setDecorators(array($this->RESETButton));
$accountFrom = $this->createElement('hidden', 'from')
->setValue(rand(1, 9999999999));
// CSR
$accountcsr = $this->createElement('hash', 'no_csr', array( 'salt' => 'unique'));
$this->addElements(array($accountDate, $accountName ,$accountProject, $accountAccountManager, $accountPunch_time, $accountOrder_time , $accountAmount , $accountSubmit , $accountButtom , $accountFrom,$accountcsr));
$this->setDecorators(array( 'FormElements','Form'));
}
private function cabForm() {
$this->setMethod('post') ;
// date
$accountDate = $this->createElement('text', 'date');
$accountDate->setValue('Date');
$accountDate->setRequired(TRUE);
$accountDate->setAttrib('size', 30);
$accountDate->setDecorators(array($this->REInput)) ;
$accountDate->setAttrib('id','cab_datepicker');
$accountDate->setAttrib('Class','date');
// name
$accountName = $this->createElement('text', 'Name');
$accountName->setValue('Name');
$accountName->setRequired(TRUE);
$accountName->setAttrib('size', 30);
$accountName->setDecorators(array($this->REInput)) ;
$accountName->setAttrib('id','cab_Name');
$accountName->setAttrib('Class','txtfld');
// Project
$accountProject = $this->createElement('text', 'Project');
$accountProject->setValue('Project');
$accountProject->setRequired(TRUE);
$accountProject->setAttrib('size', 30);
$accountProject->setDecorators(array($this->REInput)) ;
$accountProject->setAttrib('id','cab_Project');
$accountProject->setAttrib('Class','txtfld');
// AccountManager
/* $accountAccountManager = $this->createElement('text', 'AccountManager');
$accountAccountManager->setValue('Account Manager');
$accountAccountManager->setRequired(TRUE);
$accountAccountManager->setAttrib('size', 30);
$accountAccountManager->setDecorators(array($this->REInput)) ;
$accountAccountManager->setAttrib('id','cab_AccountManager');
$accountAccountManager->setAttrib('Class','txtfld'); */
$accountAccountManager = new Zend_Form_Element_Select('AccountManager');
//Pick_Up_Area for cab
$accountPick_Up_Area =$this->createElement('text', 'Pick_Up_Area');
$accountPick_Up_Area->setValue('Pickup Area');
$accountPick_Up_Area->setRequired(TRUE);
$accountPick_Up_Area->setAttrib('size', 30);
$accountPick_Up_Area->setDecorators(array($this->REInput)) ;
$accountPick_Up_Area->setAttrib('id','cab_Pick_Up_Area');
$accountPick_Up_Area->setAttrib('Class','picfrom');
//Drop_Area for cab
$accountDrop_Area =$this->createElement('text', 'Drop_Area');
$accountDrop_Area->setValue('Drop Area');
$accountDrop_Area->setRequired(TRUE);
$accountDrop_Area->setAttrib('size', 30);
$accountDrop_Area->setDecorators(array($this->REInput)) ;
$accountDrop_Area->setAttrib('id','cab_Drop_Area');
$accountDrop_Area->setAttrib('Class','picto');
}
}
private function forgotPasswordForm() {
$this->setMethod('post')
->setAttrib('id', 'forgotPassword')
->setAttrib('name', 'forgotPassword');
$emailInput= $this->createElement('text', 'Email');
$emailInput->setLabel('Enter your EmailID');
$emailInput->setRequired(TRUE);
$emailInput->setAttrib('size', 30);
$emailInput->setDecorators(array($this->Input)) ;
$emailInput->addValidator('NotEmpty', true, array('messages' => 'Error_Account_Missing_Email_Field' ));
//submit
$accountSubmit =new Zend_Form_Element_Submit('Submit');
$accountSubmit->setLabel('Submit');
$accountSubmit->setValue('Submit');
$accountSubmit->setDecorators(array($this->Button)) ;
$accountFrom = $this->createElement('hidden', 'from')
->setValue(rand(1, 9999999999));
// CSR
$accountcsr = $this->createElement('hash', 'no_csr', array( 'salt' => 'unique'));
$this->addElements(array($accountUsername,$accountPassword,$accountSubmit,$accountFrom,$accountcsr));
$this->setDecorators(array( 'FormElements','Form'));
}
}
4:Decorator:
_________________________________________________________________________________-
<?php
class Form_Decorator_ReSelect extends Zend_Form_Decorator_Abstract
{
protected $_format = '<div></div>';
public function render($content)
{
$element = $this->getElement();
$name = htmlentities($element->getFullyQualifiedName());
$label = htmlentities($element->getLabel());
$id = htmlentities($element->getId());
$value = htmlentities($element->getValue());
$markup = sprintf($this->_format,$id, $name, $value);
return $markup;
}
}
__________________________________________________________________________________________
<?php
class Form_Decorator_ReInput extends Zend_Form_Decorator_Abstract
{
protected $_format ='<div class="frmbx">
<div class="txtbxlft"></div>
<div class="txtbxmid"><input type="text" class="%s" id="%s" name="%s" value="%s" /><span>*</span></div>
<div class="txtbxrht"></div>
</div>';
public function render($content)
{
$element = $this->getElement();
$Class=htmlentities($element->getAttrib("Class"));
$id = htmlentities($element->getAttrib("id"));
$name = htmlentities($element->getFullyQualifiedName());
$value = htmlentities($element->getValue());
$markup = sprintf($this->_format, $Class, $id, $name, $value);
return $markup;
}
}
____________________________________________________________________________________________
<?php
class Form_Decorator_ReButton extends Zend_Form_Decorator_Abstract
{
protected $_format ='<div class="frmbxsubmit">
<input id="%s" name="%s" type="submit" value="" class="submitbtn">
</div>';
public function render($content)
{
$element = $this->getElement();
$name = htmlentities($element->getFullyQualifiedName());
$label = htmlentities($element->getLabel());
$id = htmlentities($element->getId());
$value = htmlentities($element->getValue());
$markup = sprintf($this->_format,$id, $name);
return $markup;
}
}
Comments
Post a Comment