当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Data_Form_Element_Abstract::setRequired方法代码示例

本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::setRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::setRequired方法的具体用法?PHP Varien_Data_Form_Element_Abstract::setRequired怎么用?PHP Varien_Data_Form_Element_Abstract::setRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Data_Form_Element_Abstract的用法示例。


在下文中一共展示了Varien_Data_Form_Element_Abstract::setRequired方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $html = '<tr>' . "\n";
     $countryId = false;
     if ($country = $element->getForm()->getElement('country_id')) {
         $countryId = $country->getValue();
     }
     $regionCollection = false;
     if ($countryId) {
         if (!isset(self::$_regionCollections[$countryId])) {
             self::$_regionCollections[$countryId] = Mage::getModel('directory/country')->setId($countryId)->getLoadedRegionCollection();
         }
         $regionCollection = self::$_regionCollections[$countryId];
     }
     $regionId = $element->getForm()->getElement('region_id')->getValue();
     if ($regionCollection && $regionCollection->getSize()) {
         $elementClass = $element->getClass();
         $element->setClass(str_replace('input-text', '', $elementClass));
         $html .= '<td class="label">' . $element->getLabelHtml() . '</td>';
         $html .= '<td class="value"><select id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" ' . $element->serialize($element->getHtmlAttributes()) . '>' . "\n";
         foreach ($regionCollection as $region) {
             $selected = $regionId == $region->getId() ? ' selected' : '';
             $html .= '<option value="' . $region->getId() . '"' . $selected . '>' . $region->getName() . '</option>';
         }
         $html .= '</select></td>';
         $element->setClass($elementClass);
     } else {
         $element->setClass('input-text');
         $html .= '<td class="label"><label for="' . $element->getHtmlId() . '">' . $element->getLabel() . ' <span class="required" style="display:none">*</span></label></td>';
         $element->setRequired(false);
         $html .= '<td class="value"><input id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" value="' . $element->getEscapedValue() . '"' . $element->serialize($element->getHtmlAttributes()) . '/></td>' . "\n";
     }
     $html .= '</tr>' . "\n";
     return $html;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:35,代码来源:Region.php

示例2: render

 /**
  * Output the region element and javasctipt that makes it dependent from country element
  *
  * @param Varien_Data_Form_Element_Abstract $element
  * @return string
  */
 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $country = $element->getForm()->getElement('country_id');
     if (!is_null($country)) {
         $countryId = $country->getValue();
     } else {
         return $element->getDefaultHtml();
     }
     $regionId = $element->getForm()->getElement('region_id')->getValue();
     $quoteStoreId = $element->getEntityAttribute()->getStoreId();
     $html = '<tr>';
     $element->setClass('input-text');
     $element->setRequired(true);
     $html .= '<td class="label">' . $element->getLabelHtml() . '</td><td class="value">';
     $html .= $element->getElementHtml();
     $selectName = str_replace('region', 'region_id', $element->getName());
     $selectId = $element->getHtmlId() . '_id';
     $html .= '<select id="' . $selectId . '" name="' . $selectName . '" class="select required-entry" style="display:none">';
     $html .= '<option value="">' . $this->_factory->getHelper('customer')->__('Please select') . '</option>';
     $html .= '</select>';
     $html .= '<script type="text/javascript">' . "\n";
     $html .= '$("' . $selectId . '").setAttribute("defaultValue", "' . $regionId . '");' . "\n";
     $html .= 'new regionUpdater("' . $country->getHtmlId() . '", "' . $element->getHtmlId() . '", "' . $selectId . '", ' . $this->helper('directory')->getRegionJsonByStore($quoteStoreId) . ');' . "\n";
     $html .= '</script>' . "\n";
     $html .= '</td></tr>' . "\n";
     return $html;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:33,代码来源:Region.php

示例3: _addAdditionalFormElementData

 /**
  * Add additional data to form element
  *
  * @param Varien_Data_Form_Element_Abstract $element
  * @return Mage_Adminhtml_Block_Sales_Order_Create_Form_Abstract
  */
 protected function _addAdditionalFormElementData(Varien_Data_Form_Element_Abstract $element)
 {
     switch ($element->getId()) {
         case 'email':
             $element->setRequired(0);
             $element->setClass('validate-email');
             break;
     }
     return $this;
 }
开发者ID:pcuervo,项目名称:gadfy,代码行数:16,代码来源:Account.php

示例4: render

 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $html = '<tr>' . "\n";
     $countryId = false;
     if ($country = $element->getForm()->getElement('country_id')) {
         $countryId = $country->getValue();
     }
     $regionCollection = false;
     if ($countryId) {
         if (!isset(self::$_regionCollections[$countryId])) {
             self::$_regionCollections[$countryId] = Mage::getModel('directory/country')->setId($countryId)->getLoadedRegionCollection()->toOptionArray();
         }
         $regionCollection = self::$_regionCollections[$countryId];
     }
     $regionId = $element->getForm()->getElement('region_id')->getValue();
     $htmlAttributes = $element->getHtmlAttributes();
     foreach ($htmlAttributes as $key => $attribute) {
         if ('type' === $attribute) {
             unset($htmlAttributes[$key]);
             break;
         }
     }
     // Output two elements - for 'region' and for 'region_id'.
     // Two elements are needed later upon form post - to properly set data to address model,
     // otherwise old value can be left in region_id attribute and saved to DB.
     // Depending on country selected either 'region' (input text) or 'region_id' (selectbox) is visible to user
     $regionHtmlName = $element->getName();
     $regionIdHtmlName = str_replace('region', 'region_id', $regionHtmlName);
     $regionHtmlId = $element->getHtmlId();
     $regionIdHtmlId = str_replace('region', 'region_id', $regionHtmlId);
     if ($regionCollection && count($regionCollection) > 0) {
         $elementClass = $element->getClass();
         $html .= '<td class="label">' . $element->getLabelHtml() . '</td>';
         $html .= '<td class="value">';
         $html .= '<select id="' . $regionIdHtmlId . '" name="' . $regionIdHtmlName . '" ' . $element->serialize($htmlAttributes) . '>' . "\n";
         foreach ($regionCollection as $region) {
             $selected = $regionId == $region['value'] ? ' selected="selected"' : '';
             $html .= '<option value="' . $region['value'] . '"' . $selected . '>' . $region['label'] . '</option>';
         }
         $html .= '</select>' . "\n";
         $html .= '<input type="hidden" name="' . $regionHtmlName . '" id="' . $regionHtmlId . '" value=""/>';
         $html .= '</td>';
         $element->setClass($elementClass);
     } else {
         $element->setClass('input-text');
         $html .= '<td class="label"><label for="' . $element->getHtmlId() . '">' . $element->getLabel() . ' <span class="required" style="display:none">*</span></label></td>';
         $element->setRequired(false);
         $html .= '<td class="value">';
         $html .= '<input id="' . $regionHtmlId . '" name="' . $regionHtmlName . '" value="' . $element->getEscapedValue() . '" ' . $element->serialize($htmlAttributes) . "/>" . "\n";
         $html .= '<input type="hidden" name="' . $regionIdHtmlName . '" id="' . $regionIdHtmlId . '" value=""/>';
         $html .= '</td>' . "\n";
     }
     $html .= '</tr>' . "\n";
     return $html;
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:55,代码来源:Region.php


注:本文中的Varien_Data_Form_Element_Abstract::setRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。