本文整理汇总了PHP中Varien_Data_Form::addElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form::addElement方法的具体用法?PHP Varien_Data_Form::addElement怎么用?PHP Varien_Data_Form::addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form
的用法示例。
在下文中一共展示了Varien_Data_Form::addElement方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
protected function _prepareForm()
{
$this->setTemplate('searchindex/form.phtml');
$model = Mage::registry('current_model');
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data'));
$general = $form->addFieldset('general', array('legend' => __('General Information')));
if ($model->getId()) {
$general->addField('index_id', 'hidden', array('name' => 'index_id', 'value' => $model->getId()));
}
$general->addField('index_code', 'select', array('label' => __('Index'), 'required' => true, 'name' => 'index_code', 'value' => $model->getIndexCode(), 'values' => Mage::getSingleton('searchindex/system_config_source_index')->toOptionArray(), 'disabled' => $model->getIndexCode() ? true : false, 'note' => Mage::helper('searchindex/help')->field('index_code')));
$general->addField('title', 'text', array('name' => 'title', 'label' => __('Title'), 'required' => true, 'value' => $model->getTitle(), 'note' => Mage::helper('searchindex/help')->field('title')));
if (!$model->getId() || !$model->getIndexInstance()->isLocked()) {
$general->addField('position', 'text', array('name' => 'position', 'label' => __('Position'), 'required' => true, 'value' => $model->getPosition(), 'note' => Mage::helper('searchindex/help')->field('position')));
$general->addField('is_active', 'select', array('name' => 'is_active', 'label' => __('Active'), 'required' => true, 'value' => $model->getIsActive(), 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => Mage::helper('searchindex/help')->field('is_active')));
}
if ($model->getId()) {
// adding attribute fieldset
$attributes = $form->addFieldset('attributes', array('legend' => __('Attributes')));
$renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset')->setTemplate('searchindex/form/renderer/fieldset/attributes.phtml')->setAvailableAttributes($model->getIndexInstance()->getAvailableAttributes())->setAttributes($model->getAttributes());
$attributes->setName('attributes')->setRenderer($renderer);
// adding additional index fieldsets
foreach ($model->getIndexInstance()->getFieldsets() as $code) {
$class = "Mirasvit_SearchIndex_Block_Adminhtml_Index_Edit_Index_{$code}";
$fieldset = new $class();
$fieldset->setModel($model->getIndexInstance())->setId($class);
$form->addElement($fieldset);
}
}
$form->setAction($this->getUrl('*/*/save'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例2: _prepareForm
protected function _prepareForm()
{
$model = Mage::registry('themeframework_area');
$form = new Varien_Data_Form();
$scopeFS = $form->addFieldset('scope_fieldset', array('legend' => Mage::helper('themeframework')->__("Scope")));
if ($model->getAreaId()) {
$scopeFS->addField('area_id', 'hidden', array('name' => 'area_id'));
}
// add Package Name element
// $scopeFS->addField('package_name', 'select', array(
// 'name' => 'package_theme',
// 'label' => Mage::helper('widget')->__('Design Package/Theme'),
// 'title' => Mage::helper('widget')->__('Design Package/Theme'),
// 'required' => true,
// 'values' => $this->getPackegeThemeOptionsArray()
// ));
// add Store ID element
if (!Mage::app()->isSingleStoreMode()) {
$field = $scopeFS->addField('store_id', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('cms')->__('Store View'), 'title' => Mage::helper('cms')->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
$field->setRenderer($renderer);
} else {
$scopeFS->addField('store_id', 'hidden', array('name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId()));
}
// add Package Name element
$el = new Varien_Data_Form_Element_Select(array('name' => 'package_theme', 'label' => Mage::helper('widget')->__('Design Package/Theme'), 'title' => Mage::helper('widget')->__('Design Package/Theme'), 'required' => true, 'values' => $this->getPackegeThemeOptionsArray(), 'onchange' => "EM_Framework.canvas.onThemeChange(this.value)"));
$el->setId('package_theme');
$form->addElement($el);
// Layout field
$scopeFS->addField('layout', 'select', array('label' => Mage::helper('themeframework')->__('Layout'), 'title' => Mage::helper('themeframework')->__('Layout'), 'name' => 'layout', 'required' => true, 'options' => array('1column' => Mage::helper('themeframework')->__('1 column'), '2columns-left' => Mage::helper('themeframework')->__('2 columns with left bar'), '2columns-right' => Mage::helper('themeframework')->__('2 columns with right bar'), '3columns' => Mage::helper('themeframework')->__('3 columns'))));
// is_active field
$scopeFS->addField('is_active', 'select', array('label' => Mage::helper('themeframework')->__('Status'), 'title' => Mage::helper('themeframework')->__('Status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => Mage::helper('themeframework')->__('Enabled'), '0' => Mage::helper('themeframework')->__('Disabled'))));
if (!$model->getId()) {
$model->setData('is_active', '1');
}
// hidden field: json_content
$scopeFS->addField('json_content', 'hidden', array('name' => 'json_content'));
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
ob_start();
?>
<script type="text/javascript">
EM_Framework.THEME_BLOCKS = <?php
echo json_encode($this->getSupportedContainerBlocks());
?>
;
EM_Framework.CANVAS_CONTENT = <?php
echo json_encode($model->getContentDecode());
?>
;
</script>
<?php
$extraHtml = ob_get_contents();
ob_end_clean();
$this->assign('extraHtml', $extraHtml);
return parent::_prepareForm();
}
示例3: generateForm
/**
* Generate HTML form
*
* @return string
*/
public function generateForm()
{
$form = new Varien_Data_Form();
$form->setAction($this->helper->getCheckoutSession()->getEmerchantPayCheckoutRedirectUrl())->setId('emerchantpay_redirect_notification')->setName('emerchantpay_redirect_notification')->setMethod('GET')->setUseContainer(true);
$submitButton = new Varien_Data_Form_Element_Submit(array('value' => $this->__('Click here, if you are not redirected within 10 seconds...')));
$submitButton->setId($this->getButtonId());
$form->addElement($submitButton);
return $form->toHtml();
}
示例4: _prepareForm
protected function _prepareForm()
{
$rateObject = new Varien_Object(Mage::getSingleton('tax/calculation_rate')->getData());
$form = new Varien_Data_Form();
$countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray();
unset($countries[0]);
if (!$rateObject->hasTaxCountryId()) {
$rateObject->setTaxCountryId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_COUNTRY));
}
if (!$rateObject->hasTaxRegionId()) {
$rateObject->setTaxRegionId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_REGION));
}
$regionCollection = Mage::getModel('directory/region')->getCollection()->addCountryFilter($rateObject->getTaxCountryId());
$regions = $regionCollection->toOptionArray();
if ($regions) {
$regions[0]['label'] = '*';
} else {
$regions = array(array('value' => '', 'label' => '*'));
}
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('tax')->__('Tax Rate Information')));
if ($rateObject->getTaxCalculationRateId() > 0) {
$fieldset->addField('tax_calculation_rate_id', 'hidden', array('name' => 'tax_calculation_rate_id', 'value' => $rateObject->getTaxCalculationRateId()));
}
$fieldset->addField('code', 'text', array('name' => 'code', 'label' => Mage::helper('tax')->__('Tax Identifier'), 'title' => Mage::helper('tax')->__('Tax Identifier'), 'class' => 'required-entry', 'required' => true));
$fieldset->addField('tax_country_id', 'select', array('name' => 'tax_country_id', 'label' => Mage::helper('tax')->__('Country'), 'required' => true, 'values' => $countries));
$fieldset->addField('tax_region_id', 'select', array('name' => 'tax_region_id', 'label' => Mage::helper('tax')->__('State'), 'values' => $regions));
$fieldset->addField('zip_is_range', 'select', array('name' => 'zip_is_range', 'label' => Mage::helper('tax')->__('Zip/Post is Range'), 'options' => array('0' => Mage::helper('tax')->__('No'), '1' => Mage::helper('tax')->__('Yes'))));
if (!$rateObject->hasTaxPostcode()) {
$rateObject->setTaxPostcode(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_POSTCODE));
}
$fieldset->addField('tax_postcode', 'text', array('name' => 'tax_postcode', 'label' => Mage::helper('tax')->__('Zip/Post Code'), 'note' => Mage::helper('tax')->__("'*' - matches any; 'xyz*' - matches any that begins on 'xyz' and not longer than %d.", Mage::helper('tax')->getPostCodeSubStringLength())));
$fieldset->addField('zip_from', 'text', array('name' => 'zip_from', 'label' => Mage::helper('tax')->__('Range From'), 'required' => true, 'maxlength' => 9, 'class' => 'validate-digits'));
$fieldset->addField('zip_to', 'text', array('name' => 'zip_to', 'label' => Mage::helper('tax')->__('Range To'), 'required' => true, 'maxlength' => 9, 'class' => 'validate-digits'));
$fieldset->addField('rate', 'text', array('name' => 'rate', 'label' => Mage::helper('tax')->__('Rate Percent'), 'title' => Mage::helper('tax')->__('Rate Percent'), 'required' => true, 'class' => 'validate-not-negative-number'));
$form->setAction($this->getUrl('*/tax_rate/save'));
$form->setUseContainer(true);
$form->setId('rate_form');
$form->setMethod('post');
if (!Mage::app()->isSingleStoreMode()) {
$form->addElement(Mage::getBlockSingleton('adminhtml/tax_rate_title_fieldset')->setLegend(Mage::helper('tax')->__('Tax Titles')));
}
$rateData = $rateObject->getData();
if ($rateObject->getZipIsRange()) {
list($rateData['zip_from'], $rateData['zip_to']) = explode('-', $rateData['tax_postcode']);
}
$form->setValues($rateData);
$this->setForm($form);
$this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')->addFieldMap('zip_is_range', 'zip_is_range')->addFieldMap('tax_postcode', 'tax_postcode')->addFieldMap('zip_from', 'zip_from')->addFieldMap('zip_to', 'zip_to')->addFieldDependence('zip_from', 'zip_is_range', '1')->addFieldDependence('zip_to', 'zip_is_range', '1')->addFieldDependence('tax_postcode', 'zip_is_range', '0'));
return parent::_prepareForm();
}
示例5: getFields
public function getFields()
{
$form = new Varien_Data_Form();
//todo add logic for getting fields by step
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
switch (intval(Mage::helper('gomage_checkout')->getConfigData('deliverydate/dateformat'))) {
case GoMage_DeliveryDate_Model_Adminhtml_System_Config_Source_Dateformat::EUROPEAN:
$dateFormatIso = 'dd.MM.yyyy';
break;
default:
$dateFormatIso = 'MM.dd.yyyy';
}
$element = new GoMage_DeliveryDate_Model_Form_Element_Date(array('name' => 'deliverydate[date]', 'label' => $this->__('Select a Date:'), 'title' => $this->__('Delivery Date'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso, 'no_span' => 1));
$element->setId('delivery_date');
$interval = intval(Mage::helper('gomage_checkout')->getConfigData('deliverydate/interval_days'));
$available_days = Mage::helper('gomage_deliverydate')->getDeliveryDays();
$available_days = array_keys($available_days);
$shift = 0;
$date_value = time() + $interval * 60 * 60 * 24;
$w = date('w', $date_value);
if (!in_array($w, $available_days)) {
if ($w > max($available_days)) {
$shift = 7 - $w + min($available_days);
} else {
foreach ($available_days as $d) {
if ($d > $w) {
$shift = $d - $w;
break;
}
}
}
}
$date_value = time() + ($interval + $shift) * (60 * 60 * 24);
while ($this->isNonWorkingDay($date_value) || !in_array(date('w', $date_value), $available_days)) {
$date_value += 60 * 60 * 24;
}
$element->setValue(date('d.m.Y', $date_value));
$form->addElement($element, false);
$values = array();
$delivery_days = Mage::helper('gomage_deliverydate')->getDeliveryDays();
if (isset($delivery_days[date('w', $date_value)])) {
$values_options = Mage::getModel('gomage_deliverydate/adminhtml_system_config_source_hour')->toOptionHash();
foreach ($delivery_days[date('w', $date_value)] as $value) {
$values[$value] = $values_options[$value];
}
}
$form->addField('delivery_time', 'select', array('name' => 'deliverydate[time]', 'title' => $this->__('Delivery Time'), 'no_span' => 1, 'values' => $values));
return $form->getElements();
}
示例6: _toHtml
/**
* Render the chooser HTML
* Target element should be set.
*
* @return string
*/
protected function _toHtml()
{
if (empty($this->_targetElementId)) {
return '';
}
$idSuffix = Mage::helper('Mage_Core_Helper_Data')->uniqHash();
$form = new Varien_Data_Form();
foreach (array('from' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('From'), 'to' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('To')) as $key => $label) {
$id = "{$key}_{$idSuffix}";
$element = new Varien_Data_Form_Element_Date(array('format' => Varien_Date::DATE_INTERNAL_FORMAT, 'label' => $label, 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'onchange' => "dateTimeChoose_{$idSuffix}()", 'value' => $this->_rangeValues[$key]));
$element->setId($id);
$form->addElement($element);
}
return $form->toHtml() . "<script type=\"text/javascript\">\n dateTimeChoose_{$idSuffix} = function() {\n \$('{$this->_targetElementId}').value = \$('from_{$idSuffix}').value + '{$this->_rangeDelimiter}' + \$('to_{$idSuffix}').value;\n };\n </script>";
}
示例7: _toHtml
protected function _toHtml()
{
$standard = Mage::getModel('paypalmx/standard');
$form = new Varien_Data_Form();
$form->setAction($standard->getConfig()->getPaypalUrl())->setId('paypal_standard_checkout')->setName('paypal_standard_checkout')->setMethod('POST')->setUseContainer(true);
foreach ($standard->getStandardCheckoutFormFields() as $field => $value) {
$form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
}
$idSuffix = Mage::helper('core')->uniqHash();
$submitButton = new Varien_Data_Form_Element_Submit(array('value' => $this->__('Click here if you are not redirected within 10 seconds...')));
$id = "submit_to_paypal_button_{$idSuffix}";
$submitButton->setId($id);
$form->addElement($submitButton);
$html = '<html><body>';
$html .= $this->__('You will be redirected to the PayPal website in a few seconds.');
$html .= $form->toHtml();
$html .= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>';
$html .= '</body></html>';
return $html;
}
示例8: _toHtml
protected function _toHtml()
{
$gateway = Mage::getModel('made_dibs/payment_gateway');
$form = new Varien_Data_Form();
$form->setAction(Made_Dibs_Model_Payment_Gateway::PAYMENTWINDOW_URL)->setId('made_dibs_gateway')->setName('made_dibs_gateway')->setMethod('POST')->setUseContainer(true);
foreach ($gateway->getCheckoutFormFields()->toArray() as $field => $value) {
$form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
}
$idSuffix = Mage::helper('core')->uniqHash();
$submitButton = new Varien_Data_Form_Element_Submit(array('value' => $this->__('Click here if you are not redirected within 10 seconds.')));
$id = "submit_to_dibs_button_{$idSuffix}";
$submitButton->setId($id);
$form->addElement($submitButton);
$html = '<html><body>';
$html .= $this->__('You will be redirected to the DIBS website in a few seconds.');
$html .= $form->toHtml();
$html .= '<script type="text/javascript">document.getElementById("made_dibs_gateway").submit();</script>';
$html .= '</body></html>';
return $html;
}
示例9: _initGroup
/**
* Init config group
*
* @param Varien_Data_Form $form
* @param Varien_Simplexml_Element $group
* @param Varien_Simplexml_Element $section
* @param Varien_Data_Form_Element_Fieldset|null $parentElement
*/
protected function _initGroup($form, $group, $section, $parentElement = null)
{
if ($group->frontend_model) {
$fieldsetRenderer = Mage::getBlockSingleton((string) $group->frontend_model);
} else {
$fieldsetRenderer = $this->_defaultFieldsetRenderer;
}
$fieldsetRenderer->setForm($this)->setConfigData($this->_configData);
if ($this->_configFields->hasChildren($group, $this->getWebsiteCode(), $this->getStoreCode())) {
$helperName = $this->_configFields->getAttributeModule($section, $group);
$fieldsetConfig = array('legend' => Mage::helper($helperName)->__((string) $group->label));
if (!empty($group->comment)) {
$fieldsetConfig['comment'] = Mage::helper($helperName)->__((string) $group->comment);
}
if (!empty($group->expanded)) {
$fieldsetConfig['expanded'] = (bool) $group->expanded;
}
$fieldset = new Varien_Data_Form_Element_Fieldset($fieldsetConfig);
$fieldset->setId($section->getName() . '_' . $group->getName())->setRenderer($fieldsetRenderer)->setGroup($group);
if ($parentElement) {
$fieldset->setIsNested(true);
$parentElement->addElement($fieldset);
} else {
$form->addElement($fieldset);
}
$this->_prepareFieldOriginalData($fieldset, $group);
$this->_addElementTypes($fieldset);
$this->_fieldsets[$group->getName()] = $fieldset;
if ($group->clone_fields) {
if ($group->clone_model) {
$cloneModel = Mage::getModel((string) $group->clone_model);
} else {
Mage::throwException($this->__('Config form fieldset clone model required to be able to clone fields'));
}
foreach ($cloneModel->getPrefixes() as $prefix) {
$this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']);
}
} else {
$this->initFields($fieldset, $group, $section);
}
}
}
示例10: _prepareForm
protected function _prepareForm()
{
$rateId = (int) $this->getRequest()->getParam('rate');
$rateObject = new Varien_Object();
$rateModel = Mage::getSingleton('tax/calculation_rate');
$rateObject->setData($rateModel->getData());
$form = new Varien_Data_Form();
$countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray();
unset($countries[0]);
$regionCollection = Mage::getModel('directory/region')->getCollection()->addCountryFilter($rateModel->getTaxCountryId());
$regions = $regionCollection->toOptionArray();
if ($regions) {
$regions[0]['label'] = '*';
} else {
$regions = array(array('value' => '', 'label' => '*'));
}
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('tax')->__('Tax Rate Information')));
if ($rateObject->getTaxCalculationRateId() > 0) {
$fieldset->addField('tax_calculation_rate_id', 'hidden', array('name' => "tax_calculation_rate_id", 'value' => $rateObject->getTaxCalculationRateId()));
}
$countryId = $rateObject->getTaxCountryId();
if (!$countryId) {
$countryId = Mage::getStoreConfig('general/country/default');
}
$fieldset->addField('code', 'text', array('name' => 'code', 'label' => Mage::helper('tax')->__('Tax Identifier'), 'title' => Mage::helper('tax')->__('Tax Identifier'), 'class' => 'required-entry', 'value' => $rateModel->getCode(), 'required' => true));
$fieldset->addField('tax_country_id', 'select', array('name' => 'tax_country_id', 'label' => Mage::helper('tax')->__('Country'), 'title' => Mage::helper('tax')->__('Please select Country'), 'class' => 'required-entry', 'required' => true, 'values' => $countries, 'value' => $countryId));
$fieldset->addField('tax_region_id', 'select', array('name' => 'tax_region_id', 'label' => Mage::helper('tax')->__('State'), 'title' => Mage::helper('tax')->__('Please select State'), 'class' => 'required-entry', 'required' => true, 'values' => $regions, 'value' => $rateObject->getTaxRegionId()));
/* FIXME!!! {*
$fieldset->addField('tax_county_id', 'select',
array(
'name' => 'tax_county_id',
'label' => Mage::helper('tax')->__('County'),
'title' => Mage::helper('tax')->__('Please select County'),
'values' => array(
array(
'label' => '*',
'value' => ''
)
),
'value' => $rateObject->getTaxCountyId()
)
);
} */
$postcode = $rateObject->getTaxPostcode();
if (!$postcode) {
$postcode = '*';
}
$fieldset->addField('tax_postcode', 'text', array('name' => 'tax_postcode', 'label' => Mage::helper('tax')->__('Zip/Post Code'), 'value' => $postcode));
if ($rateObject->getRate()) {
$value = 1 * $rateObject->getRate();
} else {
$value = 0;
}
$fieldset->addField('rate', 'text', array('name' => "rate", 'label' => Mage::helper('tax')->__('Rate'), 'title' => Mage::helper('tax')->__('Rate'), 'value' => number_format($value, 4), 'required' => true, 'class' => 'validate-not-negative-number required-entry'));
$form->setAction($this->getUrl('*/tax_rate/save'));
$form->setUseContainer(true);
$form->setId('rate_form');
$form->setMethod('post');
if (!Mage::app()->isSingleStoreMode()) {
$form->addElement(Mage::getBlockSingleton('adminhtml/tax_rate_title_fieldset')->setLegend(Mage::helper('tax')->__('Tax Titles')));
}
$this->setForm($form);
return parent::_prepareForm();
}
示例11: _toHtml
//.........这里部分代码省略.........
} elseif ($field == 'amount_5') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_6') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_7') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_8') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_9') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_10') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_11') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_12') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_13') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_14') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'amount_15') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'tax') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'tax_cart') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} elseif ($field == 'discount_amount_cart') {
$from = 'INR';
$to = 'USD';
$price = $value;
$newPrice = number_format(Mage::helper('directory')->currencyConvert($price, $from, $to), 2);
$form->addField($field, 'hidden', array('name' => $field, 'value' => $newPrice));
} else {
$form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
}
}
$idSuffix = Mage::helper('core')->uniqHash();
$submitButton = new Varien_Data_Form_Element_Submit(array('value' => $this->__('Click here if you are not redirected within 10 seconds...')));
$id = "submit_to_paypal_button_{$idSuffix}";
$submitButton->setId($id);
$form->addElement($submitButton);
$html = '<html><body>';
$html .= $this->__('You will be redirected to the PayPal website in a few seconds.');
$html .= $form->toHtml();
$html .= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>';
$html .= '</body></html>';
return $html;
}
示例12: _prepareForm
protected function _prepareForm()
{
$rateId = (int) $this->getRequest()->getParam('rate');
$rateObject = new Varien_Object();
$rateModel = Mage::getSingleton('Mage_Tax_Model_Calculation_Rate');
$rateObject->setData($rateModel->getData());
$form = new Varien_Data_Form();
$countries = Mage::getModel('Mage_Adminhtml_Model_System_Config_Source_Country')->toOptionArray();
unset($countries[0]);
if (!$rateObject->hasTaxCountryId()) {
$rateObject->setTaxCountryId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_COUNTRY));
}
if (!$rateObject->hasTaxRegionId()) {
$rateObject->setTaxRegionId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_REGION));
}
$regionCollection = Mage::getModel('Mage_Directory_Model_Region')->getCollection()->addCountryFilter($rateObject->getTaxCountryId());
$regions = $regionCollection->toOptionArray();
if ($regions) {
$regions[0]['label'] = '*';
} else {
$regions = array(array('value' => '', 'label' => '*'));
}
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Rate Information')));
if ($rateObject->getTaxCalculationRateId() > 0) {
$fieldset->addField('tax_calculation_rate_id', 'hidden', array('name' => "tax_calculation_rate_id", 'value' => $rateObject->getTaxCalculationRateId()));
}
$fieldset->addField('code', 'text', array('name' => 'code', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Identifier'), 'title' => Mage::helper('Mage_Tax_Helper_Data')->__('Tax Identifier'), 'class' => 'required-entry', 'value' => $rateModel->getCode(), 'required' => true));
$fieldset->addField('tax_country_id', 'select', array('name' => 'tax_country_id', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Country'), 'required' => true, 'values' => $countries));
$fieldset->addField('tax_region_id', 'select', array('name' => 'tax_region_id', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('State'), 'values' => $regions));
/* FIXME!!! {*
$fieldset->addField('tax_county_id', 'select',
array(
'name' => 'tax_county_id',
'label' => Mage::helper('Mage_Tax_Helper_Data')->__('County'),
'values' => array(
array(
'label' => '*',
'value' => ''
)
),
'value' => $rateObject->getTaxCountyId()
)
);
} */
$fieldset->addField('zip_is_range', 'select', array('name' => 'zip_is_range', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Zip/Post is Range'), 'options' => array('0' => Mage::helper('Mage_Tax_Helper_Data')->__('No'), '1' => Mage::helper('Mage_Tax_Helper_Data')->__('Yes'))));
if (!$rateObject->hasTaxPostcode()) {
$rateObject->setTaxPostcode(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_POSTCODE));
}
$fieldset->addField('tax_postcode', 'text', array('name' => 'tax_postcode', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Zip/Post Code'), 'note' => Mage::helper('Mage_Tax_Helper_Data')->__("'*' - matches any; 'xyz*' - matches any that begins on 'xyz' and not longer than %d.", Mage::helper('Mage_Tax_Helper_Data')->getPostCodeSubStringLength())));
$fieldset->addField('zip_from', 'text', array('name' => 'zip_from', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Range From'), 'value' => $rateObject->getZipFrom(), 'required' => true, 'class' => 'validate-digits'));
$fieldset->addField('zip_to', 'text', array('name' => 'zip_to', 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Range To'), 'value' => $rateObject->getZipTo(), 'required' => true, 'class' => 'validate-digits'));
if ($rateObject->getRate()) {
$value = 1 * $rateObject->getRate();
} else {
$value = 0;
}
$fieldset->addField('rate', 'text', array('name' => "rate", 'label' => Mage::helper('Mage_Tax_Helper_Data')->__('Rate Percent'), 'title' => Mage::helper('Mage_Tax_Helper_Data')->__('Rate Percent'), 'value' => number_format($value, 4), 'required' => true, 'class' => 'validate-not-negative-number'));
$form->setAction($this->getUrl('*/tax_rate/save'));
$form->setUseContainer(true);
$form->setId('rate_form');
$form->setMethod('post');
if (!Mage::app()->isSingleStoreMode()) {
$form->addElement(Mage::getBlockSingleton('Mage_Adminhtml_Block_Tax_Rate_Title_Fieldset')->setLegend(Mage::helper('Mage_Tax_Helper_Data')->__('Tax Titles')));
}
$form->setValues($rateObject->getData());
$this->setForm($form);
$this->setChild('form_after', $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Form_Element_Dependence')->addFieldMap("zip_is_range", 'zip_is_range')->addFieldMap("tax_postcode", 'tax_postcode')->addFieldMap("zip_from", 'zip_from')->addFieldMap("zip_to", 'zip_to')->addFieldDependence('zip_from', 'zip_is_range', '1')->addFieldDependence('zip_to', 'zip_is_range', '1')->addFieldDependence('tax_postcode', 'zip_is_range', '0'));
return parent::_prepareForm();
}