本文整理汇总了PHP中Varien_Data_Form_Element_Abstract::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Abstract::setData方法的具体用法?PHP Varien_Data_Form_Element_Abstract::setData怎么用?PHP Varien_Data_Form_Element_Abstract::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Abstract
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Abstract::setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getElementHtml
/**
* Adds some Javascript to the drop-down to place recommended defaults
*
* @param Varien_Data_Form_Element_Abstract $element
*
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$defaultSizes = array('image' => array('width' => '265', 'height' => ''), 'small_image' => array('width' => '88', 'height' => '77'), 'thumbnail' => array('width' => '75', 'height' => '75'));
$element->setData('onchange', "defaultImageSize();");
$element->setData('after_element_html', "\r\n\t\t\t<script>\r\n\t\t\t\tfunction defaultImageSize() {\r\n\t\t\t\t\tvar sizes = " . json_encode($defaultSizes) . ";\r\n\t\t\t\t\tvar size = sizes[\$('{$element->getId()}').value];\r\n\t\t\t\t\tif (size) {\r\n\t\t\t\t\t\tfor (var name in size) {\r\n\t\t\t\t\t\t\t\$('bronto_format_image_' + name).value = size[name];\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t</script>\r\n\t\t");
return parent::_getElementHtml($element);
}
示例2: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$element->setData('onchange', "apiValidation(this.form, this);");
$url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
$element->setData('after_element_html', "\n <script>\n document.observe('dom:loaded', function(){\n apiValidation();\n\n });\n function apiValidation(form, element) {\n var api_user = \$('connector_transactional_emails_credentials_api_username');\n var api_password = \$('connector_transactional_emails_credentials_api_password');\n var reloadurl = '{$url}';\n var encoded = btoa(api_password.value);\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'api_username' : api_user.value, 'api_password' : encoded},\n onComplete: function(transport) {\n Element.hide('loadingmask');\n if(transport.responseText == '\"Credentials Valid.\"'){\n api_user.setStyle({\n fontWeight: 'bold',\n color: 'green' ,\n background: 'transparent url(\"" . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'\n })\n }else{\n api_user.setStyle({\n fontWeight: 'bold',\n color: 'red',\n background: 'transparent url(\"" . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'\n });\n\n }\n }\n });\n\n return false;\n }\n\n </script>\n ");
return parent::_getElementHtml($element);
}
示例3: _getElementHtml
/**
* Override method to output our custom HTML with JavaScript
*
* @param Varien_Data_Form_Element_Abstract $element
*
* @return String
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
// Only do validation if module is installed and active
if ($this->helper('bronto_common')->isModuleInstalled('Bronto_Verify')) {
$_html = array();
// Create form object to grab scope details
$form = new Mage_Adminhtml_Block_System_Config_Form();
$scope = $form->getScope();
$scopeId = $form->getScopeId();
$element->setData('onchange', "validateToken(this.form, this);");
$element->setData('after_element_html', "\n <span id=\"loadingMask\" style=\"display: none; width: 100px;\">\n <span class=\"loader\" id=\"loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Verifying...') . "</span>\n <span id=\"loading-mask\"></span>\n </span>\n <script>\n /**\n * Function to Toggle Form Elements Disabled Status Based On Token Status\n */\n function toggleDisabled(form, element) {\n // Get Status Text Element\n var statusText = \$('bronto-validation-status-text');\n // If Status Text Element has Class of 'invalid' or empty, set boolean disabled value\n var disabled = (statusText.className == 'invalid' || statusText.className == '');\n\n // Cycle through form elements and disable/enable elements\n for (i = 0; i < form.length; i++) {\n if (form.elements[i].id != '{$element->getId()}' &&\n form.elements[i].id != 'bronto_settings_enabled' &&\n form.elements[i].id != 'verify-button' &&\n form.elements[i].type != 'hidden' &&\n form.elements[i].name.indexOf('groups') == 0) {\n form.elements[i].disabled = disabled;\n }\n }\n\n // Get Last Element of Form, and if the class name is 'note', empty the html value\n var last = element.parentNode.lastChild;\n if (last.className == 'note') {\n last.innerHTML = '';\n }\n }\n\n function trim1 (str) {\n return str.replace(/^\\s\\s*/, '').replace(/\\s\\s*\$/, '');\n }\n\n function validateToken(form, element) {\n var token = trim1(\$('{$element->getId()}').value);\n var statusText = \$('bronto-validation-status');\n var reloadUrl = '{$this->getUrl('*/apitoken/ajaxvalidation')}';\n\n statusText.innerHTML = \$('loadingMask').innerHTML;\n statusText.removeClassName('valid').removeClassName('invalid');\n\n new Ajax.Request(reloadUrl, {\n method: 'post',\n parameters: {token: token, scope: '{$scope}', scopeid: '{$scopeId}'},\n onComplete: function(transport) {\n Element.hide('loadingMask');\n statusText.innerHTML = transport.responseText;\n\n toggleDisabled(form, element);\n }\n });\n\n return false;\n }\n </script>\n ");
if (!$this->helper('bronto_common')->getApiToken()) {
$element->setComment('<span style="color:red;font-weight:bold">Please enter your Bronto API key here.</span>');
$buttonHtml = "";
} else {
$button = $this->getLayout()->createBlock('bronto_verify/adminhtml_widget_button_runtoken')->toHtml();
$buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>";
}
// Show Roundtrip Install Verification Status
$_html[] = $buttonHtml . '<style>' . ' #bronto-validation-status { color:grey; font-weight:bold; }' . ' #bronto-validation-status .valid { color: green; }' . ' #bronto-validation-status .invalid { color: red; }' . '</style>' . '<strong style="float: left; width: 80px">Last Status:</strong> ' . '<span id="bronto-validation-status">' . $this->helper('bronto_verify/apitoken')->getAdminScopedApitokenStatusText() . '</span>';
// Show everything Else
if (!empty($_html)) {
$elementHtml = $element->getElementHtml();
if ($element->getComment()) {
$elementHtml .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
$element->setComment(null);
}
$elementHtml .= '<div style="margin-top:10px">';
$elementHtml .= implode('<br />', $_html);
$elementHtml .= '</div>';
return $elementHtml;
}
}
return parent::_getElementHtml($element);
}
示例4: _getElementHtml
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$element->setData('onchange', "resetContacts();");
//url to reset the contacs
$url = Mage::helper('adminhtml')->getUrl('*/connector/resetcontactsajax');
$element->setData('after_element_html', "\n <script>\n function resetContacts(){\n new Ajax.Request('{$url}', {\n method: 'get',\n onComplete: function(transport) {\n }\n });\n return false;\n }\n </script>\n ");
return parent::_getElementHtml($element);
}
示例5: _getElementHtml
/** label */
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
//base url
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
//config code
$code = Mage::helper('ddg')->getPasscode();
if (!strlen($code)) {
$code = '[PLEASE SET UP A PASSCODE]';
}
//full url
$text = $baseUrl . 'connector/email/coupon/id/[INSERT ID HERE]/code/' . $code . '/expire_days/[INSERT NUMBER OF DAYS HERE]/@EMAIL@';
$element->setData('value', $text);
$element->setData('disabled', 'disabled');
return parent::_getElementHtml($element);
}
示例6: _getElementHtml
/** label */
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
//base url
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
//config passcode
$passcode = Mage::helper('ddg')->getPasscode();
if (!strlen($passcode)) {
$passcode = '[PLEASE SET UP A PASSCODE]';
}
//full url
$text = sprintf('%sconnector/report/bestsellers/code/%s', $baseUrl, $passcode);
$element->setData('value', $text);
$element->setData('disabled', 'disabled');
return parent::_getElementHtml($element);
}
示例7: _getElementHtml
/**
* Ajax Create the datafields.
*
* @param Varien_Data_Form_Element_Abstract $element
*
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$url = Mage::helper('adminhtml')->getUrl('*/connector/createnewdatafield');
$website = Mage::app()->getRequest()->getParam('website', 0);
$element->setData('after_element_html', "<script>\n function createDatafield(form, element) {\n var datafield_name \t= \$('connector_data_mapping_dynamic_datafield_datafield_name').value;\n var datafield_type \t= \$('connector_data_mapping_dynamic_datafield_datafield_type').value;\n var datafield_default \t= \$('connector_data_mapping_dynamic_datafield_datafield_default').value;\n var datafield_access = \$('connector_data_mapping_dynamic_datafield_datafield_access').value;\n\n var reloadurl = '{$url}';\n\n if(datafield_name && datafield_type && datafield_access){\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'name' : datafield_name, 'type' : datafield_type, 'default' : datafield_default, 'access' : datafield_access, 'website': '{$website}'},\n onComplete: function(transport) {\n window.location.reload();\n }\n });\n }\n return false;}</script>");
return parent::_getElementHtml($element);
}
示例8: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$after_element_html = $element->getAfterElementHtml();
$javaScript = "\r\n <script type=\"text/javascript\">\r\n \tif('{$element->getHtmlId()}' == 'gomage_navigation_category_show_shopby')\r\n \t{\r\n \t\tvar sel_cat = \$('gomage_navigation_category_filter_type');\r\n \t\t\r\n \t\tEvent.observe('{$element->getHtmlId()}', 'change', function(){\r\n\t var value = \$('{$element->getHtmlId()}').value; \r\n\t if (value == 1){\r\n\t \tfor(i=sel_cat.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_cat.options[i].value == '8'\r\n\t\t\t\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t\t\tsel_cat.options[i].value == '6')\r\n\t\t \t{\r\n\t\t \t\tsel_cat.remove(i);\r\n\t\t \t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n \t\r\n\t \t\t\t\t}else{\r\n\t \t\t\t\t\tvar option_fly = false;\r\n\t \t\t\t\t\tvar option_plain = false;\r\n\t \t\t\t\t\tfor(i=sel_cat.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_cat.options[i].value == '8')\r\n\t\t \t{\r\n\t\t \t\toption_fly = true;\r\n\t\t \t}\r\n\t\t \t\r\n\t\t \tif (sel_cat.options[i].value == '6')\r\n\t\t \t{\r\n\t\t \t\toption_plain = true;\r\n\t\t \t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t \t\t\t\t\tif ( !option_plain )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_cat.options[sel_cat.options.length] = new Option('Plain', '6');\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif ( !option_fly )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_cat.options[sel_cat.options.length] = new Option('Fly-Out', '8');\r\n\t\t\t\t\t\t\t}\r\n\t \t\t\t\t}\r\n\t });\r\n \t}\r\n \telse if('{$element->getHtmlId()}' == 'gomage_navigation_rightcolumnsettings_show_shopby')\r\n \t{\r\n \t\tvar sel_right = \$('gomage_navigation_rightcolumnsettings_filter_type');\r\n \t\t\r\n \t\tEvent.observe('{$element->getHtmlId()}', 'change', function(){\r\n\t var value = \$('{$element->getHtmlId()}').value; \r\n\t if (value == 1){\r\n\t \tfor(i=sel_right.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_right.options[i].value == '8'\r\n\t\t\t\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t\t\tsel_right.options[i].value == '6'\r\n\t\t\t\t\t\t\t\t\t)\r\n\t\t \t{\r\n\t\t \t\tsel_right.remove(i);\r\n\t\t \t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n \t\r\n\t \t\t\t\t}else{\r\n\t \t\t\t\t\tvar option_fly = false;\r\n\t \t\t\t\t\tvar option_plain = false;\r\n\t \t\t\t\t\tfor(i=sel_right.options.length-1;i>=0;i--)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sel_right.options[i].value == '8')\r\n\t\t \t{\r\n\t\t \t\toption_fly = true;\r\n\t\t \t}\r\n\t\t \t\r\n\t\t \tif (sel_right.options[i].value == '6')\r\n\t\t \t{\r\n\t\t \t\toption_plain = true;\r\n\t\t \t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t \t\t\t\t\tif ( !option_plain )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_right.options[sel_right.options.length] = new Option('Plain', '6');\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif ( !option_fly )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsel_right.options[sel_right.options.length] = new Option('Fly-Out', '8');\r\n\t\t\t\t\t\t\t}\r\n\t \t\t\t\t}\r\n\t });\r\n \t}\r\n \t\r\n \r\n document.observe('dom:loaded', function() { \t\r\n \tinit_{$element->getHtmlId()}(); \t\r\n });\r\n document.onreadystatechange = init_{$element->getHtmlId()};\r\n \r\n function init_{$element->getHtmlId()}() {\r\n \tGomage_Navigation_fireEvent(\$('{$element->getHtmlId()}'), 'change');\r\n }\r\n </script>";
$element->setData('after_element_html', $javaScript . $after_element_html);
return $element->getElementHtml();
}
示例9: render
/**
* Render element.
*
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$after_element_html = '<script> jQuery(function(){ jQuery("#' . $element->getHtmlId() . '").attr("style", "width: 200px !important").attr("data-hex", true).mColorPicker({ imageFolder: "' . $this->getJsUrl('olegnax/mColorPicker/') . '" }); });</script>';
$element->setData('after_element_html', $after_element_html);
$this->_element = $element;
return $this->toHtml();
}
示例10: _getElementHtml
/**
* Override method to output our custom HTML with JavaScript
*
* @param Varien_Data_Form_Element_Abstract $element
*
* @return String
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$_html = array();
$element->setData('after_element_html', "\n <span id=\"classpath-loadingmask\" style=\"display: none; width: 100px;\">\n <span class=\"loader\" id=\"classpath-loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Searching For Class Path...') . "</span>\n <span id=\"classpath-loading-mask\"></span>\n </span>\n\n <script>\n //<![CDATA[\n Event.observe(window, 'load', function() {\n var newTr = '<tr id=\"bronto_verify_advanced_classpath_results\"><td class=\"classpath_results\" colspan=\"4\"><div id=\"bronto-classpath-results\"></div></td></tr>';\n \$('" . $this->_getRowElementId($element) . "').insert({after: newTr});\n });\n function searchClasspath() {\n var reloadUrl = '{$this->getUrl('*/advanced/ajaxclasspath')}';\n var statusText = \$('bronto-classpath-results');\n\n var searchText = \$('bronto_verify_advanced_classpath_search').value;\n var classType = \$('classpath-type').value;\n\n statusText.innerHTML = \$('classpath-loadingmask').innerHTML;\n\n new Ajax.Request(reloadUrl, {\n method: 'post',\n parameters: {class: searchText, type: classType},\n onComplete: function(transport) {\n Element.hide('classpath-loadingmask');\n statusText.innerHTML = transport.responseText;\n }\n });\n\n return false;\n }\n //]]>\n </script>\n ");
// Add Class Type Selector to Input
$classTypeHtml = '<select id="classpath-type"><option value="model">Model (Default)</option><option value="helper">Helper</option><option value="block">Block</option><option value="controller">Controller</option></select>';
// Add Search Button
$button = $this->getLayout()->createBlock('bronto_verify/adminhtml_widget_button_classpath')->toHtml();
$buttonHtml = "<p class=\"form-buttons\" id=\"events-button\" style=\"float:none;\">{$button}</p>";
// Add Button to Html
$_html[] = $buttonHtml;
// Show everything Else
if (!empty($_html)) {
$elementHtml = $element->getElementHtml();
$elementHtml .= $classTypeHtml;
if ($element->getComment()) {
$elementHtml .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
$element->setComment(null);
}
$elementHtml .= '<div style="margin-top:10px">';
$elementHtml .= implode('<br />', $_html);
$elementHtml .= '</div>';
return $elementHtml;
}
return parent::_getElementHtml($element);
}
示例11: prepareElementHtml
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$html = '<script type="text/javascript">' . 'function showHideColumn(){ if(jQuery("select[name=\'parameters[widget_type]\']").val() == \'block\' && jQuery("select[name=\'parameters[scroll]\']").val() == 0) jQuery("input[name=\'parameters[column]\']").closest( "tr").hide(); else jQuery("input[name=\'parameters[column]\']").closest( "tr").show();}</script>';
$element->setOnchange('showHideColumn();');
$element->setData('after_element_html', $html);
return $element;
}
示例12: _getElementHtml
/**
* Ajax Create the addressbooks.
*
* @param Varien_Data_Form_Element_Abstract $element
*
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$url = Mage::helper('adminhtml')->getUrl('*/connector/createnewaddressbook');
$website = Mage::app()->getRequest()->getParam('website', 0);
$element->setData('after_element_html', "<script>\n function createAddressbook(form, element) {\n var name = \$('connector_sync_settings_dynamic_addressbook_addressbook_name').value;\n var visibility = \$('connector_sync_settings_dynamic_addressbook_visibility').value;\n var reloadurl = '{$url}';\n if(name && visibility){\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'name' : name, 'visibility' : visibility, 'website': '{$website}'},\n onComplete: function(transport) {\n window.location.reload();\n }\n });\n }\n return false;\n }\n </script>");
return parent::_getElementHtml($element);
}
示例13: prepareElementHtml
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$targetId = $this->getFieldsetId() . '_' . $this->getConfig('target');
$block = $this->getLayout()->createBlock('mtwidget/adminhtml_widget_renderer_depend', '', array('target' => $targetId, 'url' => $this->getUrl('mtwidget/adminhtml_widget_attribute/option'), 'me' => $element->getHtmlId(), 'value' => implode(',', (array) $element->getValue())));
$element->setData('after_element_html', $block->toHtml());
return $element;
}
示例14: _getElementHtml
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$store = null;
$disabled = false;
if ($code = $this->getRequest()->getParam('store')) {
$store = Mage::getModel('core/store')->load($code);
}
if ($store instanceof Mage_Core_Model_Store) {
/* @var Nosto_Tagging_Helper_Account $accountHelper */
$accountHelper = Mage::helper('nosto_tagging/account');
/* @var NostoAccount $nostoAccount */
$nostoAccount = $accountHelper->find($store);
if ($nostoAccount instanceof NostoAccountInterface) {
foreach (NostoApiToken::getApiTokenNames() as $token) {
if (!$nostoAccount->getApiToken($token)) {
$disabled = true;
break;
}
}
}
}
if ($disabled === true) {
/** @noinspection PhpUndefinedMethodInspection */
$element->setDisabled('disabled');
$metaOauth = new Nosto_Tagging_Model_Meta_Oauth();
/** @noinspection PhpUndefinedVariableInspection */
$metaOauth->loadData($store, $nostoAccount);
$client = new NostoOAuthClient($metaOauth);
$comment = sprintf('Your Nosto account is missing required tokens' . ' for updating settings to Nosto. Please click <a href="%s">' . ' here to re-connect</a> your account.', $client->getAuthorizationUrl());
$element->setData('comment', $comment);
}
return parent::_getElementHtml($element);
}
示例15: prepareElementHtml
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$tree = Mage::getResourceModel('cms/page_tree')->load();
$element->setData('after_element_html', $tree->toSelectHtml($element->getName(), $element->getValue(), $element->getId()));
$element->setValue();
// Not needed because page is already selected in select box
return $element;
}