本文整理汇总了PHP中Zend_Form_SubForm::setAttrib方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_SubForm::setAttrib方法的具体用法?PHP Zend_Form_SubForm::setAttrib怎么用?PHP Zend_Form_SubForm::setAttrib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_SubForm
的用法示例。
在下文中一共展示了Zend_Form_SubForm::setAttrib方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->setName('addApplicant');
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
$product = new Zend_Form_Element_Text('product');
$product->setLabel('* product:')->setRequired(true)->addFilter('StripTags')->addFilter('stringTrim')->addValidators(array(array('regex', false, array('pattern' => "/^[а,б,в,г,ґ,д,е,є,ж,з,и,ы,і,ї,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ь,ю,я,А,Б,В,С,Г,Д,Е,Є,Ж,З,И,Ы,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ь,Ю,Я,A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,1,2,3,4,5,6,7,8,9,0'.]{2,}\$/", 'messages' => 'В полі присутні заборонені символи!!'))));
$category = new Zend_Form_Element_Text('category');
$category->setLabel("* category:")->setRequired(true)->addFilter('StripTags')->addFilter('stringTrim')->addValidators(array(array('regex', false, array('pattern' => "/^[а,б,в,г,ґ,д,е,є,ж,з,и,ы,і,ї,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ь,ю,я,А,Б,В,С,Г,Д,Е,Є,Ж,З,И,Ы,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ь,Ю,Я,A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,1,2,3,4,5,6,7,8,9,0'.]{2,}\$/", 'messages' => 'В полі присутні заборонені символи!!'))));
$group = new Zend_Form_Element_Text('group');
$group->setLabel("* group:")->setRequired(true)->addFilter('StripTags')->addFilter('stringTrim')->addValidators(array(array('regex', false, array('pattern' => "/^[а,б,в,г,ґ,д,е,є,ж,з,и,ы,і,ї,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ь,ю,я,А,Б,В,С,Г,Д,Е,Є,Ж,З,И,Ы,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ь,Ю,Я,A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,1,2,3,4,5,6,7,8,9,0'.]{2,}\$/", 'messages' => 'В полі присутні заборонені символи!!'))));
$this->addElements(array($id, $product, $category, $group));
//-------------------- add attr
$institutions = new Zend_Form_SubForm();
$institutions->setName('attr');
$session = new Zend_Session_Namespace('form');
foreach ($session->attr as $inst) {
$rowForm = new Zend_Form_SubForm();
$rowForm->setName($inst);
if ($inst === '__template1__') {
$rowForm->setAttrib('style', 'display: none;');
}
$instName = new Zend_Form_Element_Text('instName');
$instName->setLabel('attribute')->addFilter('StripTags')->addFilter('stringTrim')->setAttrib('class', 'institution')->setAttrib('onfocus', 'institutionAutocomplete(this)');
if ($inst !== '__template1__') {
$instName->setRequired(true);
}
$inst_remove = new Zend_Form_Element_Button('remove');
$inst_remove->setLabel('remove')->setAttrib('class', 'remove')->setAttrib('onclick', 'removeInst(this)');
$elements = array($instName, $inst_remove);
foreach ($elements as $element) {
if ($inst !== '__template1__' && $element->getName() !== 'remove') {
$element->setRequired(true);
}
}
$rowForm->addElements($elements);
$rowForm->setElementDecorators($this->getElementDecorators());
$rowForm->getElement('remove')->removeDecorator('Label');
$rowForm->setDecorators($this->getSubFormDecorators());
$institutions->addSubForm($rowForm, $inst);
}
$institutions->setDecorators($this->getSubFormDecorators());
$inst_add = new Zend_Form_Element_Button('addInst');
$inst_add->setLabel('add attribute')->setAttrib('class', 'addInst');
$institutions->addElement($inst_add);
$institutions->setElementDecorators($this->getElementDecorators());
$institutions->getElement('addInst')->removeDecorator('Label');
$this->addSubForm($institutions, 'institutions');
$this->postSetup();
}
示例2: populate
public function populate(array $values)
{
$diseasesList = $this->_object->_diseasesSrc();
$oDiseases = new DiseasesDetailsObject();
$dData = $oDiseases->findData(array($oDiseases->getForeignKey() => $values[$this->_object->getForeignKey()]));
$fieldSet = $this->getDisplayGroup('diseases');
$i = 6;
foreach ($diseasesList as $id => $disease) {
$tmpForm = new FormDiseasesDetails(array('object' => $oDiseases, 'isXmlHttpRequest' => true));
if (!empty($values['MR_Diseases']) && in_array($id, $values['MR_Diseases'])) {
$oDiseases->setFilters(array($oDiseases->getForeignKey() => $values[$this->_object->getForeignKey()], 'DD_DiseaseId' => $id));
$data = $oDiseases->getAll();
$data[0]['DD_TypeMedic'] = explode(',', $data[0]['DD_TypeMedic']);
$tmpForm->populate($data[0]);
}
$elems = $tmpForm->getElements();
$test = new Zend_Form_SubForm();
$test->setDisableLoadDefaultDecorators(true);
$test->addElements($elems);
$test->removeDecorator('DtDdWrapper');
$test->setLegend('Détails pour ' . $disease);
$test->setAttrib('class', 'infosFieldsetParent fieldsetDiseaseDetails');
$test->setOrder($i++);
$this->addSubForm($test, 'dd_' . $id);
}
parent::populate($values);
}
示例3: __construct
/**
* Class constructor
*
* @return void
*/
public function __construct($options)
{
$this->_addSubmitSaveClose = true;
parent::__construct($options);
$imageSrc = $options['imageSrc'];
$dataId = $options['dataId'];
$imgField = $options['imgField'];
$isNewImage = $options['isNewImage'];
$moduleName = $options['moduleName'];
$productFormLeft = new Zend_Form_SubForm();
$productFormRight = new Zend_Form_SubForm();
$productFormBotPub = new Zend_Form_SubForm();
$productFormBotPro = new Zend_Form_SubForm();
if ($dataId == '') {
$pathTmp = "../../../../../data/images/" . $moduleName . "/tmp";
} else {
$pathTmp = "../../../../../data/images/" . $moduleName . "/" . $dataId . "/tmp";
}
// hidden specify if new image for the news
$newImage = new Zend_Form_Element_Hidden('isNewImage', array('value' => $isNewImage));
$newImage->removeDecorator('Label');
$productFormRight->addElement($newImage);
// Name of the product line
$name = new Zend_Form_Element_Text('PI_Name');
$name->setLabel($productFormLeft->getView()->getCibleText('product_label_name') . "<span class='field_required'>*</span>")->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $productFormLeft->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
$label = $name->getDecorator('Label');
$label->setOption('class', $this->_labelCSS);
$productFormLeft->addElement($name);
// List of sub categories
$oSubCategories = new SubCategoriesObject();
$listSubCat = $oSubCategories->subcatCollection(Zend_Registry::get('currentEditLanguage'));
$subCategories = new Zend_Form_Element_Select('P_SubCategoryID');
$subCategories->setLabel($productFormLeft->getView()->getCibleText('form_products_subcat_label') . "<span class='field_required'>*</span>")->setAttrib('class', 'largeSelect')->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $productFormLeft->getView()->getCibleText('validation_message_empty_field'))));
$subCategories->addMultiOption('', $this->getView()->getCibleText('form_select_default_label'));
$subCategories->addMultiOptions($listSubCat);
$productFormLeft->addElement($subCategories);
// Checkbox for new product
$isNewProd = new Zend_Form_Element_Checkbox('P_New');
$isNewProd->setLabel($productFormLeft->getView()->getCibleText('form_product_isnew_label'));
$isNewProd->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
$productFormLeft->addElement($isNewProd);
// id of the associated meta data
$metaTagId = new Zend_Form_Element_Hidden('PI_MetaId');
$metaTagId->removeDecorator('Label');
$productFormLeft->addElement($metaTagId);
// Image for the product line
$imageTmp = new Zend_Form_Element_Hidden($imgField . '_tmp');
$imageTmp->removeDecorator('Label');
$productFormRight->addElement($imageTmp);
$imageOrg = new Zend_Form_Element_Hidden($imgField . '_original');
$imageOrg->removeDecorator('Label');
$productFormRight->addElement($imageOrg);
$imageView = new Zend_Form_Element_Image($imgField . '_preview', array('onclick' => 'return false;'));
$imageView->setImage($imageSrc);
$productFormRight->addElement($imageView);
$imagePicker = new Cible_Form_Element_ImagePicker($imgField, array('onchange' => "document.getElementById('imageView').src = document.getElementById('" . $imgField . "').value", 'associatedElement' => $imgField . '_preview', 'pathTmp' => $pathTmp, 'contentID' => $dataId));
$imagePicker->removeDecorator('Label');
$productFormRight->addElement($imagePicker);
//Keywords field
$keywords = new Zend_Form_Element_Text('PI_MotsCles');
$keywords->setLabel($productFormLeft->getView()->getCibleText('form_product_keywords_label'))->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline marginTop30', 'id' => 'title'))))->setAttrib('class', 'largeTextInput');
$label = $keywords->getDecorator('Label');
$label->setOption('class', $this->_labelCSS);
$productFormLeft->addElement($keywords);
// Description of the product
$descrPublic = new Cible_Form_Element_Editor('PI_DescriptionPublic', array('mode' => Cible_Form_Element_Editor::ADVANCED, 'subFormID' => 'productFormBotPub'));
$descrPublic->setLabel($this->getView()->getCibleText('product_label_descriptionPublic'))->setAttrib('class', 'largeEditor');
$label = $descrPublic->getDecorator('label');
$label->setOption('class', $this->_labelCSS);
$productFormBotPub->addElement($descrPublic);
// Technical specs of the product for public.
$urlTechFile = new Zend_Form_Element_Hidden('PI_FicheTechniquePublicPDF');
$urlTechFile->removeDecorator('Label');
$productFormBotPub->addElement($urlTechFile);
$techfile = new Zend_Form_Element_Hidden('technicalSpecsName');
$techfile->removeDecorator('Label');
$productFormBotPub->addElement($techfile);
// Technical specs of the product.
$technicalSpecs = new Cible_Form_Element_FileManager('PI_FicheTechniquePublicPDF', array('associatedElement' => 'productFormBotPub', 'displayElement' => 'technicalSpecsName', 'pathTmp' => $this->_filePath, 'contentID' => $this->_dataId, 'setInit' => true));
$technicalSpecs->setLabel($productFormBotPub->getView()->getCibleText('product_label_technical_specs'))->addFilter('StripTags')->addFilter('StringTrim')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
$label = $technicalSpecs->getDecorator('Label');
$label->setOption('class', $this->_labelCSS);
$productFormBotPub->addElement($technicalSpecs);
//-----------------------------------------------------
// Description of the product for pro
$descrPro = new Cible_Form_Element_Editor('PI_DescriptionPro', array('mode' => Cible_Form_Element_Editor::ADVANCED, 'subFormID' => 'productFormBotPro'));
$descrPro->setLabel($this->getView()->getCibleText('product_label_descriptionPro'))->setAttrib('class', 'largeEditor');
$label = $descrPro->getDecorator('label');
$label->setOption('class', $this->_labelCSS);
$productFormBotPro->addElement($descrPro);
// Technical specs of the product for pro.
$urlTechFile = new Zend_Form_Element_Hidden('PI_FicheTechniqueProPDF');
$urlTechFile->removeDecorator('Label');
$productFormLeft->addElement($urlTechFile);
$techfile = new Zend_Form_Element_Hidden('technicalSpecsPro');
//.........这里部分代码省略.........
示例4: __construct
public function __construct($options = null)
{
$this->_disabledDefaultActions = true;
parent::__construct($options);
$this->setAttrib('id', 'accountManagement');
$this->setAttrib('class', 'step2');
$baseDir = $this->getView()->baseUrl();
//Hidden fields for the state and cities id
$selectedState = new Zend_Form_Element_Hidden('selectedState');
$selectedState->removeDecorator('label');
$selectedCity = new Zend_Form_Element_Hidden('selectedCity');
$selectedCity->removeDecorator('label');
$this->addElement($selectedState);
$this->addElement($selectedCity);
/* billing address */
// Billing address
$addressFacturationSub = new Zend_Form_SubForm();
$addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper');
$addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend'));
$addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormOrder');
$billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub);
$billingAddr->setProperty('addScriptState', false);
$billingAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel'));
$billingAddr->formAddress();
$addrBill = new Zend_Form_Element_Hidden('addrBill');
$addrBill->removeDecorator('label');
$addressFacturationSub->addElement($addrBill);
$this->addSubForm($addressFacturationSub, 'addressFact');
/* delivery address */
$addrShip = new Zend_Form_Element_Hidden('addrShip');
$addrShip->removeDecorator('label');
$addressShippingSub = new Zend_Form_SubForm();
$addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper');
$addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend'));
$addressShippingSub->setAttrib('class', 'addresseShippingClass subFormOrder');
$shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub);
$shipAddr->duplicateAddress($addressShippingSub);
$shipAddr->setProperty('addScriptState', false);
$shipAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'city', 'zipCode', 'country', 'firstTel', 'secondTel'));
$shipAddr->formAddress();
$addressShippingSub->addElement($addrShip);
$this->addSubForm($addressShippingSub, 'addressShipping');
// $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement');
// $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement')))
// ->setDecorators(array(
// 'ViewHelper',
// array('label', array('placement' => 'append')),
// array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')),
// ));
//
// $this->addElement($termsAgreement);
//Means of payment
$paymentMeans = new Zend_Form_Element_Select('paymentMeans');
$paymentMeans->setLabel($this->getView()->getCibleText('form_label_payment_means'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'stdTextInput')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'selectPayment'))));
$paymentMeans->addMultiOption('', $this->getView()->getClientText('cart_details_select_choose_label'));
$paymentMeans->addMultiOption('visa', $this->getView()->getCibleText('form_label_payement_visa'));
$paymentMeans->addMultiOption('mastercard', $this->getView()->getCibleText('form_label_payement_mastercard'));
$paymentMeans->addMultiOption('compte', $this->getView()->getCibleText('form_label_payement_account'));
$paymentMeans->addMultiOption('cod', $this->getView()->getCibleText('form_label_payement_cod'));
$this->addElement($paymentMeans);
// Submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel($this->getView()->getCibleText('form_label_next_step_btn'))->setAttrib('class', 'nextStepButton')->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'stepBottomNext'))));
$this->addElement($submit);
}
示例5: __construct
public function __construct($options = null)
{
$this->_disabledDefaultActions = true;
parent::__construct($options);
$baseDir = $this->getView()->baseUrl();
if (!empty($options['mode']) && $options['mode'] == 'edit') {
$this->_mode = 'edit';
} else {
$this->_mode = 'add';
}
$langId = Zend_Registry::get('languageID');
$this->setAttrib('id', 'accountManagement');
$this->setAttrib('class', 'step3');
// $addressParams = array(
// "fieldsValue" => array(),
// "display" => array(),
// "required" => array(),
// );
//Hidden fields for the state and cities id
$selectedState = new Zend_Form_Element_Hidden('selectedState');
$selectedState->removeDecorator('label');
$selectedCity = new Zend_Form_Element_Hidden('selectedCity');
$selectedCity->removeDecorator('label');
$this->addElement($selectedState);
$this->addElement($selectedCity);
// Salutation
$salutation = new Zend_Form_Element_Select('salutation');
$salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallTextInput')->setOrder(1);
$greetings = $this->getView()->getAllSalutation();
foreach ($greetings as $greeting) {
$salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']);
}
// language hidden field
$language = new Zend_Form_Element_Hidden('language', array('value' => $langId));
$language->removeDecorator('label');
// langauge hidden field
// FirstName
$firstname = new Zend_Form_Element_Text('firstName');
$firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(2);
// LastName
$lastname = new Zend_Form_Element_Text('lastName');
$lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(3);
// email
$regexValidate = new Cible_Validate_Email();
$regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
$emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
$emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound');
$email = new Zend_Form_Element_Text('email');
$email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setOrder(4);
if ($this->_mode == 'add') {
$email->addValidator($emailNotFoundInDBValidator);
}
// email
// password
$password = new Zend_Form_Element_Password('password');
if ($this->_mode == 'add') {
$password->setLabel($this->getView()->getCibleText('form_label_password'));
} else {
$password->setLabel($this->getView()->getCibleText('form_label_newPwd'));
}
$password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setRequired(true)->setOrder(5)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
// password
// password confirmation
$passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation');
if ($this->_mode == 'add') {
$passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
} else {
$passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'));
}
$passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(6)->setAttrib('class', 'stdTextInput');
if (!empty($_POST['identification']['password'])) {
$passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty'))));
$Identical = new Zend_Validate_Identical($_POST['identification']['password']);
$Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame')));
$passwordConfirmation->addValidator($Identical);
}
// password confirmation
// Company name
$company = new Zend_Form_Element_Text('company');
$company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setOrder(7)->setAttribs(array('class' => 'stdTextInput'));
// function in company
$functionCompany = new Zend_Form_Element_Text('functionCompany');
$functionCompany->setLabel($this->getView()->getCibleText('form_label_account_function_company'))->setRequired(false)->setOrder(8)->setAttribs(array('class' => 'stdTextInput'));
// Are you a retailer
$retailer = new Zend_Form_Element_Select('isRetailer');
$retailer->setLabel($this->getView()->getClientText('form_label_retailer'))->setAttrib('class', 'smallTextInput');
$retailer->addMultiOption(0, $this->getView()->getCibleText('button_no'));
$retailer->addMultiOption(1, $this->getView()->getCibleText('button_yes'));
// Text Subscribe
$textSubscribe = $this->getView()->getCibleText('form_label_subscribe');
$textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->page_privacy_policy->pageID), $textSubscribe);
// Newsletter subscription
$newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription');
$newsletterSubscription->setLabel($textSubscribe);
if ($this->_mode == 'add') {
$newsletterSubscription->setChecked(1);
}
$newsletterSubscription->setAttrib('class', 'long-text');
$newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
if ($this->_mode == 'add') {
//.........这里部分代码省略.........
示例6: form
public function form($values = array())
{
$config = Zend_Registry::get('config');
$form = new Zend_Form();
$form->setAttrib('id', 'eventForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
$workshop = new Workshop();
$where = $workshop->getAdapter()->quoteInto('status = ?', 'enabled');
$workshops = $workshop->fetchAll($where, 'title');
$workshopList = array();
foreach ($workshops as $w) {
$workshopList[$w->workshopId] = $w->title;
}
$workshopElement = $form->createElement('select', 'workshop', array('label' => 'Workshop:'));
$workshopElement->setMultiOptions($workshopList)->setValue(isset($values['workshopId']) ? $values['workshopId'] : '');
$location = new Location();
$where = $location->getAdapter()->quoteInto('status = ?', 'enabled');
$locations = $location->fetchAll($where, 'name');
$locationList = array();
$locationCapacity = array();
foreach ($locations as $l) {
$locationList[$l->locationId] = $l->name;
$locationCapacity['loc_' . $l->locationId] = $l->capacity;
}
$locationIds = array_keys($locationList);
// add the location capacities to the page in js so we can process it as a json object for the "live" max size changing with location selection
Zend_Layout::getMvcInstance()->getView()->headScript()->appendScript('var locationCapacitiesString = ' . Zend_Json::encode($locationCapacity) . ';');
$locationElement = $form->createElement('select', 'location', array('label' => 'Location:'));
$locationElement->setMultiOptions($locationList)->setValue(isset($values['locationId']) ? $values['locationId'] : $locationCapacity['loc_' . $locationIds[0]]);
$date = $form->createElement('text', 'date', array('label' => 'Date:'));
$date->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '128')->setAttrib('style', 'width: 200px')->setValue(isset($values['date']) ? strftime('%A, %B %e, %Y', strtotime($values['date'])) : '');
$password = $form->createElement('text', 'password', array('label' => 'Event Password:'));
$password->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '100')->setValue(isset($values['password']) ? $values['password'] : '');
// add the start time selector
$startTimeSub = new Zend_Form_SubForm();
$startTimeSub->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form'))));
$startTimeSub->setAttrib('class', 'sub');
$startTimeHour = $startTimeSub->createElement('select', 'hour', array('label' => 'Start Time:'));
for ($i = 1; $i <= 12; $i++) {
$startTimeHour->addMultiOption($i, $i);
}
$startTimeHour->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label')));
$startTimeHour->setValue(isset($values['startTime']) ? date('g', strtotime($values['startTime'])) : date('g'));
$startTimeMinute = $startTimeSub->createElement('select', 'minute');
for ($i = 0; $i < 60; $i += 5) {
$startTimeMinute->addMultiOption(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT));
}
$startTimeMinute->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
$startTimeMinute->setValue(isset($values['startTime']) ? date('i', strtotime($values['startTime'])) : date('i'));
$startTimeMeridian = $startTimeSub->createElement('select', 'meridian');
$startTimeMeridian->addMultiOption('am', 'AM')->addMultiOption('pm', 'PM')->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
$startTimeMeridian->setValue(isset($values['startTime']) ? date('a', strtotime($values['startTime'])) : date('a'));
$startTimeSub->addElements(array($startTimeHour, $startTimeMinute, $startTimeMeridian));
// add the end time selector
$endTimeSub = new Zend_Form_SubForm();
$endTimeSub->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form'))));
$endTimeSub->setAttrib('class', 'sub');
$endTimeHour = $endTimeSub->createElement('select', 'hour', array('label' => 'End Time:'));
for ($i = 1; $i <= 12; $i++) {
$endTimeHour->addMultiOption($i, $i);
}
$endTimeHour->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label')));
$endTimeHour->setValue(isset($values['endTime']) ? date('g', strtotime($values['endTime'])) : date('g'));
$endTimeMinute = $endTimeSub->createElement('select', 'minute');
for ($i = 0; $i < 60; $i += 5) {
$endTimeMinute->addMultiOption(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT));
}
$endTimeMinute->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
$endTimeMinute->setValue(isset($values['endTime']) ? date('i', strtotime($values['endTime'])) : date('i'));
$endTimeMeridian = $endTimeSub->createElement('select', 'meridian');
$endTimeMeridian->addMultiOption('am', 'AM')->addMultiOption('pm', 'PM')->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect'))));
$endTimeMeridian->setValue(isset($values['endTime']) ? date('a', strtotime($values['endTime'])) : date('a'));
$endTimeSub->addElements(array($endTimeHour, $endTimeMinute, $endTimeMeridian));
// get all the users available for the instructor list
$otAccount = new Ot_Account();
$accounts = $otAccount->fetchAll(null, array('lastName', 'firstName'))->toArray();
$instructorList = array();
foreach ($accounts as $a) {
$instructorList[$a['accountId']] = $a['lastName'] . ", " . $a['firstName'];
}
$instructorElement = $form->createElement('multiselect', 'instructors', array('label' => 'Instructor(s):'));
$instructorElement->setMultiOptions($instructorList)->setAttrib('size', 10)->setValue(isset($values['instructorIds']) ? $values['instructorIds'] : '');
$minSize = $form->createElement('text', 'minSize', array('label' => 'Min Size:'));
$minSize->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setAttrib('style', 'width: 50px;')->setValue(isset($values['minSize']) ? $values['minSize'] : $config->user->defaultMinWorkshopSize->val);
$maxSize = $form->createElement('text', 'maxSize', array('label' => 'Max Size:'));
$maxSize->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setAttrib('style', 'width: 50px;')->setValue(isset($values['maxSize']) ? $values['maxSize'] : $locationElement->getValue());
$waitlistSize = $form->createElement('text', 'waitlistSize', array('label' => 'Waitlist Size:'));
$waitlistSize->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setAttrib('style', 'width: 50px;')->setValue(isset($values['waitlistSize']) ? $values['waitlistSize'] : $config->user->defaultWorkshopWaitlistSize->val);
$evaluationType = $form->createElement('select', 'evaluationType', array('label' => 'Evaluation Type:'));
$evaluationType->setMultiOptions(array('default' => 'Default', 'google' => 'Google Form'))->setRequired(true)->setValue(isset($values['evaluationType']) ? $values['evaluationType'] : 'default');
$formKey = $form->createElement('textarea', 'formKey', array('label' => 'Google Form Question Key:'));
$formKey->setAttribs(array('cols' => '10', 'rows' => '5', 'style' => 'width : 250px;'))->addDecorators(array('ViewHelper', 'Errors', 'HtmlTag', array('Label', array('tag' => 'span')), array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div', 'id' => 'formKey', 'class' => 'elm'))))->setValue(isset($values['formKey']) ? $values['formKey'] : '');
$answerKey = $form->createElement('textarea', 'answerKey', array('label' => 'Google Form Answer Key:'));
$answerKey->addFilter('StringTrim')->addFilter('StripTags')->setAttribs(array('cols' => '10', 'rows' => '3', 'style' => 'width : 250px;'))->addDecorators(array('ViewHelper', 'Errors', 'HtmlTag', array('Label', array('tag' => 'span')), array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div', 'id' => 'answerKey', 'class' => 'elm'))))->setValue(isset($values['answerKey']) ? $values['answerKey'] : '');
$submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
$submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
$cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
$cancel->setAttrib('id', 'cancel');
$cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
$form->addElements(array($workshopElement, $locationElement, $password, $date, $evaluationType))->addSubForms(array('startTime' => $startTimeSub, 'endTime' => $endTimeSub))->addElements(array($minSize, $maxSize, $waitlistSize, $instructorElement));
$form->addDisplayGroup(array('instructors'), 'instructors-group', array('legend' => 'Instructors'));
//.........这里部分代码省略.........
示例7: __construct
/**
* Class constructor
*
* @return void
*/
public function __construct($options = null)
{
parent::__construct($options);
$labelCSS = Cible_FunctionsGeneral::getLanguageLabelColor($options);
$imageSrc = $options['imageSrc'];
$dataId = $options['dataId'];
$imgField = $options['imgField'];
$isNewImage = $options['isNewImage'];
$moduleName = $options['moduleName'];
$formItemPrices = new Zend_Form_SubForm();
$formTop = new Zend_Form_SubForm();
$formBottom = new Zend_Form_SubForm();
// $this = new Zend_Form_SubForm();
if ($dataId == '') {
$pathTmp = "../../../../../data/images/" . $moduleName . "/tmp";
} else {
$pathTmp = "../../../../../data/images/" . $moduleName . "/" . $dataId . "/tmp";
}
// hidden specify if new image for the news
// $newImage = new Zend_Form_Element_Hidden('isNewImage', array('value' => $isNewImage));
// $newImage->removeDecorator('Label');
// $this->addElement($newImage);
// Name of the product line
$name = new Zend_Form_Element_Text('II_Name');
$name->setLabel($this->getView()->getCibleText('item_label_name') . "<span class='field_required'>*</span>")->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
$label = $name->getDecorator('Label');
$label->setOption('class', $this->_labelCSS);
$formTop->addElement($name);
// List of products
$oProducts = new ProductsObject();
$listProd = $oProducts->productsCollection(Zend_Registry::get('currentEditLanguage'));
$products = new Zend_Form_Element_Select('I_ProductID');
$products->setLabel($this->getView()->getCibleText('form_item_products_label') . "<span class='field_required'>*</span>")->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'largeSelect')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))));
$products->addMultiOption('', $this->getView()->getCibleText('form_select_default_label'));
$products->addMultiOptions($listProd);
// foreach ($listProd as $data)
// {
// $products->addMultiOption($data['P_ID'], $data['PI_Name']);
// }
$formTop->addElement($products);
// Product
$productCode = new Zend_Form_Element_Text('I_ProductCode');
$productCode->setLabel($this->getView()->getCibleText('form_product_code_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
$formTop->addElement($productCode);
// Item sequence
$sequence = new Zend_Form_Element_Text('I_Seq');
$sequence->setLabel($this->getView()->getCibleText('form_product_sequence_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
$formTop->addElement($sequence);
// Detail Price
$detailPrice = new Zend_Form_Element_Text('I_PriceDetail');
$detailPrice->setLabel($this->getView()->getCibleText('form_item_pricedetail_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
$formTop->addElement($detailPrice);
// Pro price
$proPrice = new Zend_Form_Element_Text('I_PricePro');
$proPrice->setLabel($this->getView()->getCibleText('form_item_pricepro_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
$formTop->addElement($proPrice);
//********************************************************
//* Sub form containing data defining prices and volumes *
//********************************************************
$txtQty = new Cible_Form_Element_Html('lblQty', array('value' => $this->getView()->getCibleText('form_item_qty_label')));
$txtQty->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline left'))));
$formItemPrices->addElement($txtQty);
$txtPrices = new Cible_Form_Element_Html('lblPrices', array('value' => $this->getView()->getCibleText('form_item_prices_label')));
$txtPrices->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline right'))));
$formItemPrices->addElement($txtPrices);
// Qty limit 1
$qtyInf = new Zend_Form_Element_Text('I_LimitVol1');
$qtyInf->setLabel($this->getView()->getCibleText('form_item_limitvol1_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColLeft'))))->setAttrib('class', 'smallTextInput left');
$formItemPrices->addElement($qtyInf);
// Price Vol 1
$firstPrice = new Zend_Form_Element_Text('I_PriceVol1');
$firstPrice->removeDecorator('Label')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight'))))->setAttrib('class', 'smallTextInput');
$formItemPrices->addElement($firstPrice);
// Qty limit 2
$qtyMiddle = new Zend_Form_Element_Text('I_LimitVol2');
$qtyMiddle->setLabel($this->getView()->getCibleText('form_item_limitvol2_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColLeft'))))->setAttrib('class', 'smallTextInput textRight');
$formItemPrices->addElement($qtyMiddle);
// Price vol 2
$secondPrice = new Zend_Form_Element_Text('I_PriceVol2');
$secondPrice->removeDecorator('Label')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight', 'id' => 'title'))))->setAttrib('class', 'smallTextInput textRight');
$formItemPrices->addElement($secondPrice);
// Price vol 3
$thirdPrice = new Zend_Form_Element_Text('I_PriceVol3');
$thirdPrice->setLabel($this->getView()->getCibleText('form_item_priceVol3_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight'))))->setAttrib('class', 'smallTextInput textRight');
$formItemPrices->addElement($thirdPrice);
//********************************************************
$special = new Zend_Form_Element_Checkbox('I_Special');
$special->setLabel($this->getView()->getCibleText('form_item_special_label'));
$special->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
$formBottom->addElement($special);
// Special Price
$specialPrice = new Zend_Form_Element_Text('I_PrixSpecial');
$specialPrice->setLabel($this->getView()->getCibleText('form_item_specialPrice_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
$formBottom->addElement($specialPrice);
// Checkbox for tax of the province
//.........这里部分代码省略.........