本文整理汇总了PHP中Zend_Form_Element_Radio::addMultiOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Radio::addMultiOptions方法的具体用法?PHP Zend_Form_Element_Radio::addMultiOptions怎么用?PHP Zend_Form_Element_Radio::addMultiOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Radio
的用法示例。
在下文中一共展示了Zend_Form_Element_Radio::addMultiOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
$radioKind = new Zend_Form_Element_Radio('kind');
$radioKind->addMultiOptions(array('and' => 'and', 'or' => 'or'));
$radioKind->setValue('and');
$radioKind->setLabel('Search field combination:');
$radioKind->setRequired(true);
$this->addElement($radioKind);
$fishSampleCode = new Zend_Form_Element_Text(Fish::COL_SAMPLE_CODE);
$fishSampleCode->setLabel('Fish Sample Code:');
//---------------------------------------------------------
//read the available image attributes from attribute descriptor+group image
$metadata = new Default_MetaData();
$fishRowSetArray = $metadata->getAttributesComplete('fish');
//----------------------------------------------------------
$this->addDynamicElements($fishRowSetArray, true);
$this->addElement($fishSampleCode);
$this->addElement('submit', 'submit', array('label' => 'search'));
$this->addElement('hidden', 'Token');
$this->setElementFilters(array('StringTrim'));
//#####################new###################################
$this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'dynamic_form')), array('Description', array('placement' => 'prepend')), 'Form'));
$this->setElementDecorators(array('ViewHelper', 'Errors', array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td')), array('Label', array('tag' => 'td')), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))));
$this->setSubFormDecorators(array('FormElements', array('HtmlTag', array('tag' => 'tr'))));
foreach ($this->getSubForms() as $index => $subform) {
$subform->setElementDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')), array('Label', array('tag' => 'td'), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))));
}
$this->submit->setDecorators(array(array('decorator' => 'ViewHelper', 'options' => array('helper' => 'formSubmit')), array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td', 'colspan' => 2)), array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr'))));
//###########################################################
}
示例2: __construct
public function __construct($forSearch = false)
{
parent::__construct();
if ($forSearch) {
$radioKind = new Zend_Form_Element_Radio('kind');
$radioKind->addMultiOptions(array('and' => 'and', 'or' => 'or'));
$radioKind->setValue('and');
$radioKind->setLabel('Search field combination:');
$radioKind->setRequired(true);
$this->addElement($radioKind);
}
$this->addElement('hidden', CalibrationExercise::COL_ID, array('required' => true));
$this->addElement('hidden', CalibrationExercise::COL_WORKSHOP_ID, array('required' => true));
$valiAlphaWhiteSpace = new Zend_Validate_Alpha(true);
$valiAlnumWhiteSpace = new Zend_Validate_Alnum(true);
$this->addElement('text', CalibrationExercise::COL_NAME, array('label' => 'Calibration exercise name:', 'required' => true, 'validators' => array($valiAlnumWhiteSpace)));
$this->addElement('text', CalibrationExercise::COL_DESCRIPTION, array('label' => 'Description:', 'required' => true, 'validators' => array($valiAlnumWhiteSpace)));
$this->addElement(new Default_Form_Element_KeyTableSelect(CalibrationExercise::COL_KEY_TABLE_ID, array('label' => 'Protocol:', 'required' => true, 'validators' => array($valiAlnumWhiteSpace))));
$this->addElement(new Default_Form_Element_ExpertiseSelect(CalibrationExercise::COL_EXPERTISE_ID, array('label' => 'Expertise:', 'required' => true, 'validators' => array($valiAlnumWhiteSpace))));
$this->addElement('checkbox', CalibrationExercise::COL_COMPAREABLE, array('label' => 'Show comparable other user/group annotations/references:', 'required' => true));
$this->addElement('checkbox', CalibrationExercise::COL_RANDOMIZED, array('label' => 'Allow adding images to image set at random:', 'required' => true));
$this->addElement('submit', 'save', array('label' => 'Save'));
$this->addElement('hidden', 'Token');
$this->addElement('hidden', CalibrationExercise::COL_IS_STOPPED);
}
示例3: init
public function init()
{
global $mySession;
$PathType = '1';
if (isset($_REQUEST['path_type'])) {
$PathType = $_REQUEST['path_type'];
}
$video_title = new Zend_Form_Element_Text('video_title');
$video_title->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Video title is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "textInput");
$pathtypeArr = array();
$pathtypeArr[0]['key'] = "1";
$pathtypeArr[0]['value'] = "Computer";
$pathtypeArr[1]['key'] = "2";
$pathtypeArr[1]['value'] = "You Tube Url";
$path_type = new Zend_Form_Element_Radio('path_type');
$path_type->addMultiOptions($pathtypeArr)->setAttrib("onclick", "setType(this.value);")->setValue(1);
$video_path = new Zend_Form_Element_File('video_path');
$video_path->setDestination(SITE_ROOT . 'images/videos/')->addValidator('Extension', false, 'flv');
$you_tube_url = new Zend_Form_Element_Text('you_tube_url');
$you_tube_url->setAttrib("class", "textInput");
if ($PathType == '1') {
$video_path->setRequired(true)->addDecorator('Errors', array('class' => 'error'));
} else {
$you_tube_url->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'You tube url is required.'))->addDecorator('Errors', array('class' => 'error'));
}
$this->addElements(array($video_title, $video_path, $you_tube_url, $path_type));
}
示例4: _getPrivacyFormElements
/** helper method to create privacy related form elements */
protected function _getPrivacyFormElements()
{
$privacy = new Zend_Form_Element_Radio('privacy');
$privacy->addMultiOptions(array(MIDAS_COMMUNITY_PRIVATE => $this->t('Private, only members can see the community'), MIDAS_COMMUNITY_PUBLIC => $this->t('Public, everyone can see the community')))->setRequired(true)->setValue(MIDAS_COMMUNITY_PUBLIC);
$canJoin = new Zend_Form_Element_Radio('canJoin');
$canJoin->addMultiOptions(array(MIDAS_COMMUNITY_CAN_JOIN => $this->t('Everyone can join the community'), MIDAS_COMMUNITY_INVITATION_ONLY => $this->t('Only invited users can join the community')))->setValue(MIDAS_COMMUNITY_CAN_JOIN);
return array($privacy, $canJoin);
}
示例5: _initVOType
public function _initVOType()
{
$element = new Zend_Form_Element_Radio('vo_type');
$element->addMultiOptions(array('MIXED' => 'Mixed', 'GROUP' => 'Group', 'STEM' => 'Stem', 'IDP' => 'IdP'));
$element->setRequired(true);
$element->setAllowEmpty(false);
$element->setValue('MIXED');
return $this->addElement($element);
}
示例6: buildCat2Element
protected function buildCat2Element()
{
$cat2 = new Zend_Form_Element_Radio('cat2');
$cat2->setLabel($this->_business->getCat2Name());
$cat2->addMultiOptions($this->_business->getCat2Array(null, false));
$cat2->setValue($this->_business->getFirstCat2(null, false));
$cat2->setAttrib('class', 'refineformselect');
$cat2->setAttrib('onclick', "changeCat2(this.id,this.value, '/ajax/realestate/changecat2/')");
$this->addElement($cat2);
}
示例7: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'feedforwardinit');
$id = new Zend_Form_Element_Hidden('id');
$postid = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
$appraisal_mode = new Zend_Form_Element_Select('appraisal_mode');
$appraisal_mode->setLabel("Appraisal");
$appraisal_mode->setMultiOptions(array('' => 'Select Appraisal'));
$appraisal_mode->setAttrib('class', 'selectoption');
$appraisal_mode->setRequired(true);
$appraisal_mode->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal.'));
$status = new Zend_Form_Element_Select('status');
$status->setLabel("Status");
$status->setAttrib('class', 'selectoption');
$status->setMultiOptions(array('1' => 'Open'));
//,'2' => 'Close'
$status->setRegisterInArrayValidator(false);
$status->setRequired(true);
$status->addValidator('NotEmpty', false, array('messages' => 'Please select status.'));
$employee_name_view = new Zend_Form_Element_Radio('employee_name_view');
$employee_name_view->setLabel("Employee Details");
$employee_name_view->addMultiOptions(array('1' => 'Show', '0' => 'Hide'));
$employee_name_view->setSeparator('');
$employee_name_view->setValue(0);
$employee_name_view->setRegisterInArrayValidator(false);
$enable_to = new Zend_Form_Element_MultiCheckbox('enable_to');
$enable_to->setLabel("Enable To");
$enable_to->addMultiOptions(array('0' => 'Appraisal Employees', '1' => 'All Employees'));
$enable_to->setSeparator('');
$enable_to->setValue(0);
$enable_to->setRequired(true);
$enable_to->setRegisterInArrayValidator(false);
$enable_to->addValidator('NotEmpty', false, array('messages' => 'Please check enable to.'));
$ff_due_date = new Zend_Form_Element_Text('ff_due_date');
$ff_due_date->setLabel("Due Date");
$ff_due_date->setOptions(array('class' => 'brdr_none'));
$ff_due_date->setRequired(true);
$ff_due_date->addValidator('NotEmpty', false, array('messages' => 'Please select due date.'));
$save = new Zend_Form_Element_Submit('submit');
$save->setAttrib('id', 'submitbutton');
$save->setLabel('Save & Initialize');
$save_later = new Zend_Form_Element_Submit('submit');
$save_later->setAttrib('id', 'submitbutton1');
$save_later->setLabel('Save & Initialize Later');
$this->addElements(array($id, $appraisal_mode, $status, $employee_name_view, $ff_due_date, $save, $save_later, $enable_to));
$this->setElementDecorators(array('ViewHelper'));
}
示例8: init
public function init($val)
{
global $mySession;
$db = new Db();
# FORM ELEMENT:Email ID
# TYPE : text
$fname = new Zend_Form_Element_Text('fname');
$fname->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'First name is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'changepasstextbox');
//if($val==1)
// {
// $fname->setValue($mySession->fname);
// }
# FORM ELEMENT:Email ID
# TYPE : text
$lname = new Zend_Form_Element_Text('lname');
$lname->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Last name is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'changepasstextbox');
$PaypalArr = array();
$PaypalArr[0]['key'] = "1";
$PaypalArr[0]['value'] = "PayPal";
$PaypalArr[1]['key'] = "2";
$PaypalArr[1]['value'] = "Credit Card";
$paypalchk = new Zend_Form_Element_Radio('paypalchk');
$paypalchk->addMultiOptions($PaypalArr)->addValidator('NotEmpty', true, array('messages' => 'Payment Mode is required.'))->addDecorator('Errors', array('class' => 'error'))->setRequired(true);
//$paypalchk= new Zend_Form_Element_Checkbox('paypalchk');
// $paypalchk
// ->setRequired(true)
// ->addValidator('NotEmpty',true,array('messages' =>'Last name is required'))
// ->addDecorator('Errors', array('class'=>'errmsg'));
//
//
// $creditchk= new Zend_Form_Element_Checkbox('creditchk');
// $creditchk
// ->setRequired(true)
// ->addValidator('NotEmpty',true,array('messages' =>'Last name is required'))
// ->addDecorator('Errors', array('class'=>'errmsg'));
# FORM ELEMENT:password
# TYPE : text
$emailid = new Zend_Form_Element_Text('emailid');
$emailid->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Email Id is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'changepasstextbox');
if (@$_REQUEST['emailid'] != "") {
$emailid->addValidator('EmailAddress', true)->addDecorator('Errors', array('class' => 'errmsg'))->addErrorMessage('Please enter a valid email address');
}
$this->addElements(array($fname, $lname, $emailid, $paypalchk));
}
示例9: __construct
public function __construct($forSearch = false)
{
parent::__construct();
if ($forSearch) {
$radioKind = new Zend_Form_Element_Radio('kind');
$radioKind->addMultiOptions(array('and' => 'and', 'or' => 'or'));
$radioKind->setValue('and');
$radioKind->setLabel('Search field combination:');
$radioKind->setRequired(true);
$this->addElement($radioKind);
}
$this->addElement('hidden', CalibrationExercise::COL_ID, array('required' => true));
$valiAlphaWhiteSpace = new Zend_Validate_Alpha(true);
$valiAlnumWhiteSpace = new Zend_Validate_Alnum(true);
$this->addElement('text', CalibrationExercise::COL_NAME, array('label' => 'Calibration exercise name:', 'required' => true, 'validators' => array($valiAlnumWhiteSpace)));
$this->addElement('text', CalibrationExercise::COL_DESCRIPTION, array('label' => 'Description:', 'required' => true, 'validators' => array($valiAlnumWhiteSpace)));
$this->addElement('submit', 'save', array('label' => 'Save'));
$this->addElement('hidden', 'Token');
}
示例10: __construct
public function __construct($options = null)
{
// $this->_disabledDefaultActions = true;
// $this->_object = $options['object'];
unset($options['object']);
parent::__construct($options);
// Subform for the retailer status on website
$retailerForm = new Cible_Form_SubForm();
$retailerForm->setName('retailerForm')->removeDecorator('DtDdWrapper');
//checkbox to set the retailers address as valid
$isValid = new Zend_Form_Element_Checkbox('R_Active');
$isValid->setLabel($this->getView()->getCibleText('form_label_approved_onweb'));
$isValid->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
$retailerForm->addElement($isValid);
$isRetailer = new Zend_Form_Element_Radio('isDistributeur');
$isRetailer->setLabel($this->getView()->getCibleText('form_label_Display_web'))->setOrder(0);
$isRetailer->setSeparator('');
$isRetailer->setAttrib('class', 'vertAlignRadio');
$isRetailer->addMultiOptions(array(1 => $this->getView()->getCibleText('form_account_no'), 2 => $this->getView()->getCibleText('form_account_yes')))->setValue(1);
$txtFr = new Cible_Form_Element_Html('lblFr', array('value' => $this->getView()->getCibleText('form_address_retailer_fr')));
$txtFr->setOrder(1)->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'formLanguage'))));
$retailerForm->addElement($txtFr);
$adressRetailer = new Cible_View_Helper_FormAddress($retailerForm);
$adressRetailer->enableFields(array('name' => true, 'firstAddress' => false, 'secondAddress' => false, 'state' => false, 'cityTxt' => false, 'zipCode' => false, 'country' => false, 'firstTel' => false, 'secondTel' => false, 'fax' => false, 'email' => false, 'webSite' => false));
$adressRetailer->formAddress();
$retailerForm->addElement($isRetailer);
$retailerForm->getElement('AI_SecondTel')->setAttrib('class', 'stdTextInput phoneFree');
// Subform for the retailer status on website
$retailerFormEn = new Cible_Form_SubForm();
$retailerFormEn->setName('retailerFormEn')->removeDecorator('DtDdWrapper');
$txtEn = new Cible_Form_Element_Html('lblEn', array('value' => $this->getView()->getCibleText('form_address_retailer_en')));
$txtEn->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'formLanguage'))));
$adressRetailerEn = new Cible_View_Helper_FormAddress($retailerFormEn);
$adressRetailerEn->enableFields(array('name' => false, 'firstAddress' => false, 'secondAddress' => false, 'firstTel' => false, 'secondTel' => false, 'webSite' => false));
$adressRetailerEn->formAddress();
$retailerFormEn->addElement($txtEn);
$retailerFormEn->getElement('AI_SecondTel')->setAttrib('class', 'stdTextInput phoneFree');
//*** Add subform to the form ***/
$this->addSubForm($retailerForm, 'retailerForm');
$this->addSubForm($retailerFormEn, 'retailerFormEn');
}
示例11: __construct
public function __construct($forSearch = false)
{
parent::__construct();
if ($forSearch) {
$radioKind = new Zend_Form_Element_Radio('kind');
$radioKind->addMultiOptions(array('and' => 'and', 'or' => 'or'));
$radioKind->setValue('and');
$radioKind->setLabel('Search field combination:');
$radioKind->setRequired(true);
$this->addElement($radioKind);
}
$valiAlphaWhiteSpace = new Zend_Validate_Alpha(true);
$this->addElement('hidden', User::COL_ID, array('required' => true));
$this->addElement('text', User::COL_USERNAME, array('label' => 'Username = e-mail adress:', 'required' => true, 'validators' => array('EmailAddress', array('StringLength', false, array(6, 40)))));
$this->addElement('text', User::COL_FIRSTNAME, array('label' => 'First name:', 'required' => true, 'validators' => array($valiAlphaWhiteSpace)));
$this->addElement('text', User::COL_LASTNAME, array('label' => 'Last name:', 'required' => true, 'validators' => array($valiAlphaWhiteSpace)));
$this->addElement('password', User::COL_PASSWORD, array('label' => 'Password:', 'required' => true, 'validators' => array(array('StringLength', false, array(6, 20)))));
$this->addElement('password', self::PASSWORD_CLONE, array('label' => 'Repeat Password:', 'required' => true));
//due to the rule username=e-mail adress, this field is not viewed
/* $this->addElement('text', User::COL_EMAIL, array( 'label'=>'E-mail adress:',
'required'=>true,
'validators'=>array('EmailAddress')));*/
$institutionSelect = new Default_Form_Element_ValuelistSelect(603, User::COL_INSTITUTION);
$institutionSelect->setRequired(true);
$institutionSelect->setLabel('Institution:');
$this->addElement($institutionSelect);
$this->addElement('text', User::COL_STREET, array('label' => 'Street:', 'validators' => array(new Zend_Validate_Alnum(true))));
$this->addElement('text', User::COL_CITY, array('label' => 'City:', 'validators' => array($valiAlphaWhiteSpace)));
$this->addElement('text', User::COL_PHONE, array('label' => 'Phone number:'));
$this->addElement('text', User::COL_FAX, array('label' => 'Faxsimile number:'));
$countrySelect = new Default_Form_Element_ValuelistSelect(602, User::COL_COUNTRY);
$countrySelect->setRequired(true);
$countrySelect->setLabel('Country:');
$this->addElement($countrySelect);
$this->addElement('checkbox', User::COL_ACTIVE, array('label' => 'Active:'));
$this->addElement('hidden', User::COL_GUID);
$this->addElement('submit', 'submit', array('label' => 'Submit'));
$this->addElement('hidden', 'Token');
$this->setElementFilters(array('StringTrim'));
}
示例12: init
public function init()
{
$this->setMethod('post');
//$this->setAttrib('action',DOMAIN.'language/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'appraisalconfig');
$id = new Zend_Form_Element_Hidden('id');
$postid = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
$businessunit_id = new Zend_Form_Element_Select('businessunit_id');
$businessunit_id->setLabel("Business Unit");
$businessunit_id->setAttrib('class', 'selectoption');
if ($postid == '') {
$businessunit_id->setAttrib('onchange', 'displayDept(this)');
$bunitdata = $this->bunitdata;
if (!empty($bunitdata)) {
$businessunit_id->addMultiOptions(array('' => 'Select Business unit', '0' => 'No Business Unit'));
foreach ($bunitdata as $data) {
$businessunit_id->addMultiOption($data['id'], $data['unitname']);
}
} else {
$businessunit_id->addMultiOptions(array('' => 'Select Business unit'));
}
} else {
$businessunit_id->addMultiOptions(array('' => 'Select Business unit'));
}
$businessunit_id->setRegisterInArrayValidator(false);
$businessunit_id->setRequired(true);
$businessunit_id->addValidator('NotEmpty', false, array('messages' => 'Please select business unit.'));
$department_id = new Zend_Form_Element_Select('department_id');
$department_id->setLabel("Department");
$department_id->setAttrib('class', 'selectoption');
$department_id->addMultiOption('', 'Select Department');
if ($postid == '') {
$department_id->setAttrib('onchange', 'displayDept(this)');
}
$department_id->setRegisterInArrayValidator(false);
$performance_app_flag = new Zend_Form_Element_Radio('performance_app_flag');
$performance_app_flag->setLabel("Applicability");
$performance_app_flag->setAttrib('onclick', 'checkimplementfun(this)');
$performance_app_flag->addMultiOptions(array('1' => 'Business unit wise', '0' => 'Department wise'));
$performance_app_flag->setSeparator('');
$performance_app_flag->setValue(1);
$performance_app_flag->setRegisterInArrayValidator(false);
$performance_app_flag->setRequired(true);
$performance_app_flag->addValidator('NotEmpty', false, array('messages' => 'Please select applicability.'));
$appraisal_mode = new Zend_Form_Element_Select('appraisal_mode');
$appraisal_mode->setLabel("Appraisal Mode");
$appraisal_mode->setAttrib('class', 'selectoption');
$appraisal_mode->addMultiOptions(array('' => 'Select appraisal mode', 'Quarterly' => 'Quarterly', 'Half-yearly' => 'Half-yearly', 'Yearly' => 'Yearly'));
$appraisal_mode->setRegisterInArrayValidator(false);
$appraisal_mode->setRequired(true);
$appraisal_mode->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal mode.'));
$appraisal_ratings = new Zend_Form_Element_Select('appraisal_ratings');
$appraisal_ratings->setLabel("Appraisal Ratings");
$appraisal_ratings->setAttrib('class', 'selectoption');
$appraisal_ratings->addMultiOptions(array('' => 'Select ratings', '1' => '1-5', '2' => '1-10'));
$appraisal_ratings->setRegisterInArrayValidator(false);
$appraisal_ratings->setRequired(true);
$appraisal_ratings->addValidator('NotEmpty', false, array('messages' => 'Please select appraisal ratings.'));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $businessunit_id, $performance_app_flag, $department_id, $appraisal_mode, $appraisal_ratings, $submit));
$this->setElementDecorators(array('ViewHelper'));
}
示例13: getRadios
/**
* Get Radio Option
* @param string $id
* @param array $option
* @param string $value
* @return Zend_Form_Element_Radio
*/
public function getRadios($id, $option, $value = '', $elementequired = false)
{
$element = new Zend_Form_Element_Radio($id);
$element->addMultiOptions($option);
$element->removeDecorator('HtmlTag');
$element->removeDecorator('DtDdWrapper');
$element->removeDecorator('Label');
$element->setSeparator('<br/>');
if ($value !== '') {
$element->setValue($value);
}
if ($elementequired) {
$element->setAttribs(array('class' => 'validate[required] radio'));
}
return $element;
}
示例14: _htmlRadio
/**
* 以<radio>标签的形式输出
*
* @param ZtChart_Model_DbTable_Role_Rowset $rowset
* @param array $attributes
*/
protected function _htmlRadio(ZtChart_Model_DbTable_Role_Rowset $rowset, $attributes = array())
{
if (isset($attributes['options'])) {
$options = $attributes['options'];
unset($attributes['options']);
} else {
$options = array();
}
$htmlRadio = new Zend_Form_Element_Radio(array_merge($this->_attributes['radio'], $attributes));
$htmlRadio->clearDecorators()->addDecorator('ViewHelper');
$htmlRadio->addMultiOptions($options);
foreach ($rowset as $row) {
$htmlRadio->addMultiOption($row->role_id, $row->role_name);
}
return $htmlRadio;
}
示例15: init
public function init()
{
$this->setMethod('post');
$this->setAttrib('action', BASE_URL . 'timemanagement/expenses/edit');
$this->setAttrib('id', 'formid');
$this->setAttrib('name', 'expensecategory');
$id = new Zend_Form_Element_Hidden('id');
$client = new Zend_Form_Element_Select('client_id');
$client->addMultiOption('', 'Select Client');
$client->setRegisterInArrayValidator(false);
$client->setAttrib('onchange', 'loadProjects(this)');
$client->setRequired(true);
$client->addValidator('NotEmpty', false, array('messages' => 'Please select Client.'));
$client->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_clients', 'field' => 'id', 'exclude' => 'is_active = 1')));
$client->getValidator('Db_RecordExists')->setMessage('Selected Client is inactivated.');
$project = new Zend_Form_Element_Select('project_id');
$project->addMultiOption('', 'Select Project');
$project->setRegisterInArrayValidator(false);
$project->setRequired(true);
$project->addValidator('NotEmpty', false, array('messages' => 'Please select Project.'));
$project->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_projects', 'field' => 'id', 'exclude' => 'is_active = 1')));
$project->getValidator('Db_RecordExists')->setMessage('Selected Project is inactivated.');
$category = new Zend_Form_Element_Select('expense_cat_id');
$category->addMultiOption('', 'Select Category');
$category->setRegisterInArrayValidator(false);
$category->setRequired(true);
$category->addValidator('NotEmpty', false, array('messages' => 'Please select Category.'));
$category->addValidator(new Zend_Validate_Db_RecordExists(array('table' => 'tm_expense_categories', 'field' => 'id', 'exclude' => 'is_active = 1')));
$category->getValidator('Db_RecordExists')->setMessage('Selected Category is inactivated.');
$expenseDate = new ZendX_JQuery_Form_Element_DatePicker('expense_date');
$expenseDate->setOptions(array('class' => 'brdr_none'));
//$date_of_leaving->setAttrib('onchange', 'validatejoiningdate(this)');
$expenseDate->setAttrib('readonly', 'true');
$expenseDate->setAttrib('onfocus', 'this.blur()');
$expenseAmount = new Zend_Form_Element_Text('expense_amount');
$expenseAmount->setAttrib('maxLength', 8);
$expenseAmount->setLabel("Unit Price");
$expenseAmount->addValidator("regex", true, array('pattern' => '/^[1-9]\\d{1,4}(\\.\\d{1,2})?$/', 'messages' => array('regexNotMatch' => 'Please enter valid Amount.')));
$note = new Zend_Form_Element_Text('note');
$note->setAttrib('maxLength', 200);
$note->setLabel("Note");
$billable = new Zend_Form_Element_Radio('is_billable');
$billable->setLabel("Type");
$billable->addMultiOptions(array('1' => 'Yes', '0' => 'No'));
$billable->setSeparator('');
$billable->setValue('billable');
$billable->setRegisterInArrayValidator(false);
$billable->setRequired(true);
$billable->addValidator('NotEmpty', false, array('messages' => 'Please select Type.'));
/*
client_idbigint(20) unsigned NOT NULL
project_idbigint(20) unsigned NOT NULL
expense_cat_idint(10) unsigned NOT NULL
expense_datetimestamp NOT NULL
expense_amountdecimal(8,2) unsigned NOT NULL
notevarchar(200) NULL
is_billabletinyint(1) unsigned NOT NULL
receipt_filevarchar(200) NULL
expense_statusenum('saved','submitted','approved','rejected') NULL
status_update_datetimestamp NOT NULL
status_update_byint(11) NULL
reject_notevarchar(200) NULL
*/
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$submit->setLabel('Save');
$this->addElements(array($id, $client, $project, $category, $expenseDate, $expenseAmount, $note, $billable, $submit));
$this->setElementDecorators(array('ViewHelper'));
$this->setElementDecorators(array('UiWidgetElement'), array('expense_date'));
}