本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::getForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::getForm方法的具体用法?PHP Varien_Data_Form_Element_Abstract::getForm怎么用?PHP Varien_Data_Form_Element_Abstract::getForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::getForm方法的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: 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: 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;
}
示例5: _getElementHtml
/**
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
/** @var Mage_SalesRUle_Model_Rule $salesRuleModel */
$salesRuleModel = Mage::getModel('salesrule/rule');
/** @var Mage_Widget_Block_Adminhtml_Widget_Options $widgetOptions */
$widgetOptions = $element->getForm()->getParent();
$widgetValues = $widgetOptions->getWidgetValues();
if ($widgetValues && isset($widgetValues['rule'])) {
$rules = unserialize(base64_decode($widgetValues['rule']));
$salesRuleModel->loadPost($rules);
$salesRuleModel->getConditions()->setJsFormObject('rule_conditions_fieldset');
$salesRuleModel->getActions()->setJsFormObject('rule_actions_fieldset');
}
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('rule_');
/** @var Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset $renderer */
$renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')->setTemplate('rapidcampaign/fieldset.phtml')->setNewChildUrl($this->getUrl('*/promo_quote/newConditionHtml/form/rule_conditions_fieldset'));
$fieldset = $form->addFieldset('conditions_fieldset', array())->setRenderer($renderer);
$fieldset->addField('conditions', 'text', array('name' => 'conditions', 'label' => Mage::helper('salesrule')->__('Conditions'), 'title' => Mage::helper('salesrule')->__('Conditions'), 'required' => true))->setRule($salesRuleModel)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
$fieldset->addClass('fieldset-nowrap');
$form->setValues($salesRuleModel->getData());
Mage::register('rapidcampaign/widget/created', true, true);
$html = $form->toHtml();
if ($element->getNote()) {
$html .= '<p class="note"><span>' . $element->getNote() . '</span></p>';
}
return $html;
}
示例6: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$form = $element->getForm();
$parent = $form->getParent();
$scope = $parent->getScope();
$scopeId = $parent->getScopeId();
if ($scope == 'stores') {
$store = Mage::app()->getStore($scopeId);
} elseif ($scope == 'websites') {
$store = Mage::app()->getWebsite($scopeId);
} else {
$store = Mage::app()->getStore(0);
}
try {
$helper = Mage::helper('pay_payment');
$helper->loadOptions($store);
$arrOptions = $helper->getOptions($store);
$output = '';
foreach ($arrOptions as $option) {
$output .= '<img src="' . $option->getImage() . '" /> ' . $option->getName() . '<br />';
}
} catch (Exception $e) {
$output = $e->getMessage();
}
return '<div>' . $output . '</div>';
}
示例7: _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;
}
示例8: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$editor = new TM_Core_Block_Adminhtml_Widget_Form_Element_Wysiwyg($element->getData());
$editor->setId($element->getId());
$editor->setForm($element->getForm());
return parent::render($editor);
}
示例9: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$buttonBlock = $element->getForm()->getParent()->getLayout()->createBlock('adminhtml/widget_button');
$params = array('website' => $buttonBlock->getRequest()->getParam('website'));
$data = array('label' => Mage::helper('adminhtml')->__('Export CSV'), 'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("zitec_dpd/adminhtml_config/exportTablerates", $params) . '\')', 'class' => '');
$html = $buttonBlock->setData($data)->toHtml();
return $html;
}
示例10: render
/**
* Add the 'Use Config Settings' checkbox to the input element
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$id = 'use_config_' . $element->getId();
$checkbox = new Varien_Data_Form_Element_Checkbox(array('html_id' => $id, 'name' => $id));
$checkbox->setForm($element->getForm());
$checkbox->setAfterElementHtml(' <label for="' . $id . '">' . $this->helper('adminhtml')->__('Use Config Settings') . '</label>' . $this->getElementJs());
$checkbox->setOnclick(sprintf("if(this.checked){\$('%s').disabled=true;}else{\$('%s').disabled=false;}", $element->getForm()->getHtmlIdPrefix() . $element->getId(), $element->getForm()->getHtmlIdPrefix() . $element->getId()));
if (!$element->getValue()) {
$checkbox->setChecked(true);
$element->setDisabled(true);
if (preg_match("/^carousel_([a-z_]{1,})\$/", $element->getId(), $result)) {
$element->setValue(Mage::getStoreConfig('ibanners/carousel/' . $result[1]));
}
}
$element->setNote($checkbox->getElementHtml());
return parent::render($element);
}
示例11: render
/**
* Checkbox render function
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$checkbox = new Varien_Data_Form_Element_Checkbox($element->getData());
$checkbox->setForm($element->getForm());
$elementHtml = $checkbox->getElementHtml() . sprintf('<label for="%s"><b>%s</b></label><p class="note">%s</p>', $element->getHtmlId(), $element->getLabel(), $element->getNote());
$html = '<td class="label"> </td>';
$html .= '<td class="value">' . $elementHtml . '</td>';
return $html;
}
示例12: _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();
}
示例13: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$editor = new Varien_Data_Form_Element_Editor($element->getData());
// Prevent foreach error
$editor->getConfig()->setPlugins(array());
$editor->setId($element->getId());
$editor->setForm($element->getForm());
$editor->setValue(base64_decode($editor->getValue()));
return parent::render($editor);
}
示例14: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$editor = new Varien_Data_Form_Element_Editor($element->getData());
// Prevent foreach error
$editor->getConfig()->setPlugins(array());
$editor->setId($element->getId());
$editor->setForm($element->getForm());
$editor->setWysiwyg(true);
$editor->setForceLoad(true);
return parent::render($editor);
}
示例15: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$__html = '';
if (!Mage::app()->isSingleStoreMode()) {
$__replacingElement = new Varien_Data_Form_Element_Select();
$__replacingElement->setData($element->getData());
$__replacingElement->setForm($element->getForm());
$__html = parent::render($__replacingElement);
}
return $__html;
}