本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::getClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::getClass方法的具体用法?PHP Varien_Data_Form_Element_Abstract::getClass怎么用?PHP Varien_Data_Form_Element_Abstract::getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::getClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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 = intval($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"' : '';
$value = is_numeric($region['value']) ? (int) $region['value'] : "";
$html .= '<option value="' . $value . '"' . $selected . '>' . Mage::helper('adminhtml')->escapeHtml(Mage::helper('directory')->__($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;
}
示例3: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$color = new Varien_Data_Form_Element_Text();
$data = array('name' => $element->getName(), 'html_id' => $element->getId());
$color->setData($data);
$color->setValue($element->getValue(), $format);
$color->setForm($element->getForm());
$color->addClass('color ' . $element->getClass());
return $color->getElementHtml();
}