2

In system.xml file, I have declared a button as below:

<import_customer translate="label comment">
                <label>Import Customer</label>
                <comment><![CDATA[Import customers data]]></comment>
                <frontend_type>button</frontend_type>
                <frontend_model>cemimport/adminhtml_system_config_form_button</frontend_model>
                <action_url>module/importer/customers</action_url>
                <sort_order>1</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>0</show_in_website>
                <show_in_store>1</show_in_store>
            </import_customer>

Is there any way for me to get <action_url> value inside the _getElementHtml method?

class Namespace_Module_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
    {
}
1

You can try:

Mage::app()->getConfig()->getSections()

hopefully Mage::app()->getConfig() returns a Mage_Adminhtml_Model_Config class

0

You may use something like this:

 protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
    {
        return $this->_toHtml();
    }

Then in your template file:

<?php echo $this->getButtonHtml() ?>
0

Inside your _getElementHtml method you can retrieve the value of the <action_url> field from system.xml like this:

$data = $element->getOriginalData();
$actionUrl = $data['action_url'];

Or like this, checking if the field exists:

$data = $element->getOriginalData();
$actionUrl = NULL;
if (isset($data['action_url']))
{
    $actionUrl = $data['action_url'];
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.