本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::getName方法的具体用法?PHP Varien_Data_Form_Element_Abstract::getName怎么用?PHP Varien_Data_Form_Element_Abstract::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _getElementHtml
/**
* @param Varien_Data_Form_Element_Abstract $element
*
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$element->addClass('select');
$hours = 0;
$minutes = 0;
if ($value = $element->getValue()) {
$values = explode(',', $value);
if (is_array($values) && count($values) == 2) {
$hours = $values[0];
$minutes = $values[1];
}
}
$optionTemplate = '<option value="%s" %s>%s</option>';
$html = sprintf('<input type="hidden" id="%s" />', $element->getHtmlId());
$html .= sprintf('<select name="%s" %s style="width:60px">', $element->getName(), $element->serialize($element->getHtmlAttributes()));
for ($i = 0; $i < 24; $i++) {
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
$html .= sprintf($optionTemplate, $hour, (int) $hours === $i ? 'selected="selected"' : '', $hour);
}
$html .= '</select> : ';
$html .= sprintf('<select name="%s" %s style="width:60px">', $element->getName(), $element->serialize($element->getHtmlAttributes()));
for ($i = 0; $i < 60; $i++) {
$minute = str_pad($i, 2, '0', STR_PAD_LEFT);
$html .= sprintf($optionTemplate, $minute, (int) $minutes === $i ? 'selected="selected"' : '', $minute);
}
$html .= '</select>';
$html .= $element->getAfterElementHtml();
return $html;
}
示例3: prepareElementHtml
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$config = $this->getConfig();
$chooseButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setClass('scalable btn-chooser')->setLabel($config['button']['open'])->setOnclick('MediabrowserUtility.openDialog(\'' . $this->getUrl('*/cms_wysiwyg_images/index', array('target_element_id' => $element->getName())) . '\')')->setDisabled($element->getReadonly());
$text = new Varien_Data_Form_Element_Text();
$text->setForm($element->getForm())->setId($element->getName())->setName($element->getName())->setClass('widget-option input-text');
if ($element->getRequired()) {
$text->addClass('required-entry');
}
if ($element->getValue()) {
$text->setValue($element->getValue());
}
$element->setData('after_element_html', $text->getElementHtml() . $chooseButton->toHtml());
return $element;
}
示例4: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$_years = array(null => "Year");
for ($i = 0, $y = (int) date("Y"); $i < 5; $i++, $y++) {
$_years[$y] = $y;
}
$_months = array(null => "Month");
for ($i = 1; $i <= 12; $i++) {
$_months[$i] = Mage::app()->getLocale()->date(mktime(null, null, null, $i))->get(Zend_date::MONTH_NAME);
}
$_days = array(null => "Day");
for ($i = 1; $i <= 31; $i++) {
$_days[$i] = $i < 10 ? '0' . $i : $i;
}
if ($element->getValue()) {
$values = explode(',', $element->getValue());
} else {
$values = array();
}
$element->setName($element->getName() . '[]');
$_yearsHtml = $element->setStyle('width:75px;')->setValues($_years)->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml();
$_monthsHtml = $element->setStyle('width:100px;')->setValues($_months)->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml();
$_daysHtml = $element->setStyle('width:50px;')->setValues($_days)->setValue(isset($values[2]) ? $values[2] : null)->getElementHtml();
return sprintf('%s %s %s', $_yearsHtml, $_monthsHtml, $_daysHtml);
}
示例5: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$res = '';
$divId = $element->getId();
$res .= <<<EOD
\t\t<input name="{$element->getName()}" id="{$divId}_date" value="{$element->getValue()}" type="text" style="width:130px !important;" /> <img src="{$this->getSkinUrl('images/grid-cal.gif')}" alt="" id="{$divId}_date_trig" title="{$this->__('Select Date')}" style="" />
\t\t<script type="text/javascript">
\t\t//<![CDATA[
\t\t\t//this example uses dd.MM.yyyy hh:mm format.
\t\t\tCalendar.setup({
\t\t\t\tinputField: "{$divId}_date",
\t\t\t\tifFormat: "%Y-%m-%d %H:%M:%S",
\t\t\t\tshowsTime: true,
\t\t\t\tfirstDay: 1,
\t\t\t\ttimeFormat: "24",
\t\t\t\tbutton: "{$divId}_date_trig",
\t\t\t\talign: "Bl",
\t\t\t\tsingleClick : true
\t\t\t});
\t\t\t
\t\t//]]>
\t\t</script>
EOD;
return $res;
}
示例6: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$element->addClass('element-value-changer');
$valueName = $element->getLabel();
if ($valueName === '' || $valueName === null) {
$valueName = '...';
}
if ($element->getShowAsText()) {
$html = ' <input type="hidden" class="hidden" id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" value="' . $element->getValue() . '"/> ' . htmlspecialchars($valueName) . ' ';
} else {
$html = ' <span class="rule-param">';
/** @var Mage_Core_Model_Translate_Inline $translate */
$translate = Mage::getSingleton('core/translate_inline');
if ($translate->isAllowed()) {
$valueName = Mage::helper('core/string')->truncate($valueName, 33, '...');
}
$html .= '<a href="javascript:void(0)" class="label">';
$html .= Mage::helper('core')->escapeHtml($valueName);
$html .= '</a>';
$html .= '<span class="element"> ';
$html .= $element->getElementHtml();
if ($element->getExplicitApply()) {
/** @var Aoe_FraudManager_Helper_Data $helper */
$helper = Mage::helper('Aoe_FraudManager/Data');
$url = $helper->getConditionApplyImageUrl();
$label = $helper->getConditionApplyLabel();
$html .= ' <a href="javascript:void(0)" class="rule-param-apply">';
$html .= '<img src="' . $url . '" class="v-middle" alt="' . $label . '" title="' . $label . '" />';
$html .= '</a> ';
}
$html .= '</span>';
$html .= '</span> ';
}
return $html;
}
示例7: render
/**
* Render element
*
* @param Varien_Data_Form_Element_Abstract $element
* @see Varien_Data_Form_Element_Renderer_Interface::render()
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$element->addClass('element-value-changer');
$valueName = $element->getValueName();
if ($element instanceof Varien_Data_Form_Element_Select && $valueName == '...') {
$optionValues = $element->getValues();
foreach ($optionValues as $option) {
if ($option['value'] === '') {
$valueName = $option['label'];
}
}
}
if ($valueName === '') {
$valueName = '...';
}
if ($element->getShowAsText()) {
$html = ' <input type="hidden" class="hidden" id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" value="' . $element->getValue() . '"/> ' . htmlspecialchars($valueName) . ' ';
} else {
$html = ' <span class="rule-param"' . ($element->getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>' . '<a href="javascript:void(0)" class="label">';
$translate = Mage::getSingleton('core/translate_inline');
$html .= $translate->isAllowed() ? Mage::helper('core')->escapeHtml($valueName) : Mage::helper('core')->escapeHtml(Mage::helper('core/string')->truncate($valueName, 33, '...'));
$html .= '</a><span class="element"> ' . $element->getElementHtml();
if ($element->getExplicitApply()) {
$html .= ' <a href="javascript:void(0)" class="rule-param-apply"><img src="' . $this->getSkinUrl('M2ePro/images/rule_component_apply.gif') . '" class="v-middle" alt="' . Mage::helper('M2ePro')->__('Apply') . '" title="' . Mage::helper('M2ePro')->__('Apply') . '" /></a> ';
}
$html .= '</span></span> ';
}
return $html;
}
示例8: getElementHtml
public function getElementHtml()
{
$this->addClass('select multiselect');
$html = '';
if ($this->getCanBeEmpty() && empty($this->_data['disabled'])) {
$html .= '<input type="hidden" name="' . parent::getName() . '" value="" />';
}
$html .= '<select id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" ' . $this->serialize($this->getHtmlAttributes()) . ' multiple="multiple">' . "\n";
$value = $this->getValue();
if (!is_array($value)) {
$value = explode(',', $value);
}
if ($values = $this->getValues()) {
foreach ($values as $option) {
if (is_array($option['value'])) {
$html .= '<optgroup label="' . $option['label'] . '">' . "\n";
foreach ($option['value'] as $groupItem) {
$html .= $this->_optionToHtml($groupItem, $value);
}
$html .= '</optgroup>' . "\n";
} else {
$html .= $this->_optionToHtml($option, $value);
}
}
}
$html .= '</select>' . "\n";
$html .= $this->getAfterElementHtml();
return $html;
}
示例9: getCurrencyTableHtml
/**
* Inform the user there version will not work
* @return string
*/
private function getCurrencyTableHtml(Varien_Data_Form_Element_Abstract $element)
{
// Store ID = scope ID
$storeId = Mage::getSingleton('adminhtml/config_data')->getScopeId();
// Retrieve the currencies
$currencies = Mage::app()->getStore($storeId)->getAvailableCurrencyCodes();
// Retrieve the values
$values = $element->getValue();
// Build our response
$response = '<input type="hidden" id="payment_gene_braintree_multi_currency_mapping" />
<table width="100%" cellspacing="6" cellpadding="4">
<tr>
<th width="35%">' . $this->__('Currency Code') . '</th>
<th width="65%">' . $this->__('Merchant Account ID') . '</th>
</tr>';
// Loop through each currency and add a value
foreach ($currencies as $currency) {
$response .= '<tr>
<td> ' . $currency . '</td>
<td><input class="input-text" type="text" name=" ' . $element->getName() . '[' . $currency . ']" style="width: 100%;" value="' . (isset($values->{$currency}) ? $values->{$currency} : '') . '" /></td>
</tr>';
}
$response .= '</table>';
return $response;
}
示例10: _prepareForm
/**
* Instantiate form and fields
*
* @return Varien_Data_Form
*/
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$form->setFieldsetRenderer($this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset'));
$form->setFieldsetElementRenderer($this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element'));
$form->setDataObject($this->_parentElement->getForm()->getDataObject());
/**
* if there is a parent element defined, it will be replaced by a hidden element with the same name
* and overriden by the form elements
* It is needed to maintain HTML consistency of the parent element's form
*/
if ($this->_parentElement) {
$form->setHtmlIdPrefix($this->_parentElement->getHtmlId())->setFieldNameSuffix($this->_parentElement->getName());
$form->addField('', 'hidden', array('name' => ''));
}
$noYes = array(Mage::helper('adminhtml')->__('No'), Mage::helper('adminhtml')->__('Yes'));
// initial amount
$schedule = $form->addFieldset('initamount_fieldset', array('legend' => Mage::helper('customweb_subscription')->__('Initial Fee/Discount'), 'disabled' => $this->_isReadOnly));
$this->_addField($schedule, 'init_amount');
// schedule
$schedule = $form->addFieldset('schedule_fieldset', array('legend' => Mage::helper('customweb_subscription')->__('Schedule'), 'disabled' => $this->_isReadOnly));
$this->_addField($schedule, 'description');
$this->_addField($schedule, 'period_unit', array('options' => $this->_getPeriodUnitOptions(Mage::helper('adminhtml')->__('-- Please Select --'))), 'select');
$this->_addField($schedule, 'period_frequency');
$this->_addField($schedule, 'period_max_cycles');
$this->_addField($schedule, 'cancel_period');
$this->_addField($schedule, 'can_customer_suspend', array('options' => array(1 => Mage::helper('adminhtml')->__('Yes'), 0 => Mage::helper('adminhtml')->__('No'))), 'select');
// shipping
$shipping = $form->addFieldset('shipping_fieldset', array('legend' => Mage::helper('customweb_subscription')->__('Shipping'), 'disabled' => $this->_isReadOnly));
$this->_addElementTypes($shipping);
$this->_addField($shipping, 'shipping_amount_type', array('options' => array('fixed' => Mage::helper('customweb_subscription')->__('Fixed Shipping'), 'calculated' => Mage::helper('customweb_subscription')->__('Equals initial order'))), 'select');
$this->_addField($shipping, 'shipping_amount', array(), 'price');
return $form;
}
示例11: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$html = '';
$data = Mage::getStoreConfig('auspost/activation/data');
$ele_value = explode(',', str_replace($data, '', Mage::helper('core')->decrypt($element->getValue())));
$ele_name = $element->getName();
$ele_id = $element->getId();
$element->setName($ele_name . '[]');
$data_info = Mage::helper('auspost')->getDataInfo();
if (isset($data_info['dom']) && intval($data_info['c']) > 0 && intval($data_info['suc']) == 1) {
foreach (Mage::app()->getWebsites() as $website) {
$url = $website->getConfig('web/unsecure/base_url');
$url = Mage::helper('auspost')->getFormatUrl(trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url)));
foreach ($data_info['dom'] as $web) {
if ($web['dom'] == $url && $web['suc'] == 1) {
$element->setChecked(false);
$id = $website->getId();
$name = $website->getName();
$element->setId($ele_id . '_' . $id);
$element->setValue($id);
if (in_array($id, $ele_value) !== false) {
$element->setChecked(true);
}
if ($id != 0) {
$html .= '<div><label>' . $element->getElementHtml() . ' ' . $name . ' </label></div>';
}
}
}
}
} else {
$html = sprintf('<strong class="required">%s</strong>', $this->__('Please enter a valid key'));
}
return $html;
}
示例12: 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;
}
示例13: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$element->setStyle('display:block')->setName($element->getName() . '[]');
if ($element->getValue()) {
$values = explode(',', $element->getValue());
} else {
$values = array();
}
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
$allowedDefault = array();
$elementsJs = array();
foreach ($payments as $paymentCode => $paymentModel) {
$paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
$methodsAllowed[$paymentCode] = array('label' => $paymentTitle, 'value' => $paymentCode . "_allow");
array_push($allowedDefault, $paymentCode . "_allow");
$elementsJs[] = $element->getId() . '_' . $paymentCode . "";
}
foreach ($payments as $paymentCode => $paymentModel) {
$paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
$methodsDenied[$paymentCode] = array('label' => $paymentTitle, 'value' => $paymentCode . "_deny");
}
if (empty($values)) {
$values = $allowedDefault;
}
$from = $element->setValues($methodsAllowed)->setValue($values)->getElementHtml();
$to = $element->setValues($methodsDenied)->setValue($values)->getElementHtml();
$script = "";
foreach ($elementsJs as $elementj) {
$script .= "\n document.getElementById('" . $elementj . "_allow').addEventListener('click', function() {\n if (document.getElementById('" . $elementj . "_deny').checked == true) {\n document.getElementById('" . $elementj . "_deny').checked = false;\n } else {\n document.getElementById('" . $elementj . "_deny').checked = true;\n }\n }, false);\n document.getElementById('" . $elementj . "_deny').addEventListener('click', function() {\n if (document.getElementById('" . $elementj . "_allow').checked == true) {\n document.getElementById('" . $elementj . "_allow').checked = false;\n } else {\n document.getElementById('" . $elementj . "_allow').checked = true;\n\n }\n }, false);\n if (document.getElementById('" . $elementj . "_deny').checked == false && document.getElementById('" . $elementj . "_allow').checked == false) {\n document.getElementById('" . $elementj . "_allow').checked = true;\n }\n ";
}
return '<div style="white-space: nowrap;"><div style="display:inline-block;padding: 0 5px 0 0; width:50%">' . $from . '</div> <div style="display:inline-block;padding: 0 5px 0 0; width:50%">' . $to . '</div></div><script>' . $script . '</script>';
}
示例14: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$element->addClass('element-value-changer');
$valueName = $element->getValueName();
if ($valueName === '') {
$valueName = '...';
}
$valueLabel = htmlspecialchars(Mage::helper('core/string')->truncate($valueName, 150, '...'));
switch ($this->getFormat()) {
case 'text':
$html = $valueLabel;
break;
case 'html':
$html = '<strong>' . $valueLabel . '</strong>';
break;
default:
if ($element->getIsMeta()) {
$html = '<input type="hidden" class="hidden" id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" value="' . $element->getValue() . '"/>';
$html .= htmlspecialchars($valueName);
} else {
$html = '<span class="rule-param"' . ($element->getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>';
$html .= '<a href="javascript:void(0)" class="label">' . $valueLabel . '</a>';
$html .= '<span class="element">';
$html .= $element->getElementHtml();
if ($element->getExplicitApply()) {
$html .= '<a href="javascript:void(0)" class="rule-param-apply"><img src="' . $this->getSkinUrl('images/rule_component_apply.gif') . '" class="v-middle" alt="' . $this->__('Apply') . '" title="' . $this->__('Apply') . '" /></a>';
}
$html .= '</span></span>';
}
}
return $html;
}
示例15: 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;
}