本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::setClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::setClass方法的具体用法?PHP Varien_Data_Form_Element_Abstract::setClass怎么用?PHP Varien_Data_Form_Element_Abstract::setClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::setClass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
/**
* 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;
}
示例3: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
if ($country = $element->getForm()->getElement('country_id')) {
$countryId = $country->getValue();
} else {
return $element->getDefaultHtml();
}
$regionId = $element->getForm()->getElement('region_id')->getValue();
$html = '<tr>';
$element->setClass('input-text');
$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="">' . AO::helper('customer')->__('Please select') . '</option>';
$html .= '</select>';
$html .= '<script type="text/javascript">
if ($("' . $country->getHtmlId() . '") != undefined) {
new regionUpdater("' . $country->getHtmlId() . '", "' . $element->getHtmlId() . '", "' . $selectId . '", ' . $this->helper('directory')->getRegionJson() . ');
}
</script>';
$html .= '</td></tr>' . "\n";
return $html;
}
示例4: _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;
}
示例5: 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"' : '';
$html .= '<option value="' . (int) $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;
}
示例6: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$html = '';
$r = Mage::getStoreConfig('gomage_activation/advancednavigation/ar');
$value = explode(',', str_replace($r, '', Mage::helper('core')->decrypt($element->getValue())));
$nameprefix = $element->getName();
$idprefix = $element->getId();
$element->setName($nameprefix . '[]');
$info = Mage::helper('gomage_navigation')->ga();
if (isset($info['d']) && isset($info['c']) && intval($info['c']) > 0) {
foreach (Mage::app()->getWebsites() as $website) {
$element->setChecked(false);
$id = $website->getId();
$name = $website->getName();
$element->setId($idprefix . '_' . $id);
$element->setValue($id);
$element->setClass('gomage-navigation-available-sites');
if (in_array($id, $value) !== false) {
$element->setChecked(true);
}
if ($id != 0) {
$html .= '<div><label>' . $element->getElementHtml() . ' ' . $name . ' </label></div>';
}
}
$html .= '
<input id="' . $idprefix . '_diasbled" type="hidden" disabled="disabled" name="' . $nameprefix . '" />
<script type="text/javascript">
function updateGomageNavigationWebsites(){
$("' . $idprefix . '_diasbled").disabled = "disabled";
if($$(".gomage-navigation-available-sites:checked").length >= ' . intval($info['c']) . '){
$$(".gomage-navigation-available-sites").each(function(e){
if(!e.checked){
e.disabled = "disabled";
}
});
}else {
$$(".gomage-navigation-available-sites").each(function(e){
if(!e.checked){
e.disabled = "";
}
});
if($$(".gomage-navigation-available-sites:checked").length == 0){
$("' . $idprefix . '_diasbled").disabled = "";
}
}
}
$$(".gomage-navigation-available-sites").each(function(e){
e.observe("click", function(){
updateGomageNavigationWebsites();
});
});
updateGomageNavigationWebsites();
</script>';
} else {
$html = sprintf('<strong class="required">%s</strong>', $this->__('Please enter a valid key'));
}
return $html;
}
示例7: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$html = '';
$nameprefix = $element->getName();
$idprefix = $element->getId();
$element->setName($nameprefix . '[]');
$info = array();
$info['c'] = '5';
$info['d'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
if (isset($info['d']) && isset($info['c']) && intval($info['c']) > 0) {
foreach (Mage::app()->getWebsites() as $website) {
$element->setChecked(false);
$id = $website->getId();
$name = $website->getName();
$element->setId($idprefix . '_' . $id);
$element->setValue($id);
$element->setClass('gomage-checkout-available-sites');
if ($id !== false) {
$element->setChecked(true);
}
if ($id != 0) {
$html .= '<div><label>' . $element->getElementHtml() . ' ' . $name . ' </label></div>';
}
}
$html .= '
<input id="' . $idprefix . '_diasbled" type="hidden" disabled="disabled" name="' . $nameprefix . '" />
<script type="text/javascript">
function updateGomageCheckoutWebsites(){
$("' . $idprefix . '_diasbled").disabled = "disabled";
if($$(".gomage-checkout-available-sites:checked").length >= ' . intval($info['c']) . '){
$$(".gomage-checkout-available-sites").each(function(e){
if(!e.checked){
e.disabled = "disabled";
}
});
}else {
$$(".gomage-checkout-available-sites").each(function(e){
if(!e.checked){
e.disabled = "";
}
});
if($$(".gomage-checkout-available-sites:checked").length == 0){
$("' . $idprefix . '_diasbled").disabled = "";
}
}
}
$$(".gomage-checkout-available-sites").each(function(e){
e.observe("click", function(){
updateGomageCheckoutWebsites();
});
});
updateGomageCheckoutWebsites();
</script>';
} else {
$html = sprintf('<strong class="required">%s</strong>', $this->__('Please enter a valid key'));
}
return $html;
}