开发者

How do I update a configuration field from a frontend_model .phtml?

开发者 https://www.devze.com 2023-02-22 17:52 出处:网络
I have an admin configuration for a custom module. I have a button that makes a request to my web site and returns a code.

I have an admin configuration for a custom module. I have a button that makes a request to my web site and returns a code. In system.xml I have a field with a frontend_model specified:

<frontend_model>mymodule/adminhtml_system_config_requestCode</frontend_model>

RequestCode.php does:

protected function _prepareLayout()
{
    parent::_prepareLayout();
    if (!$this->getTemplate()) {
        $this->setTemplate('mypackage/system/config/request_code.phtml');
    }
    return $this;
}
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
    $originalData = $element->getOriginalData();
    $this->addData(array(
        'button_label' => Mage::helper('mymodule')->__($originalData['button_label']),
        'button_url'   => $originalData['button_url'],
        'html_id' => $element->getHtmlId(),
    ));
    return $this->_toHtml();
}

and request_code.phtml is:

<script>
    function requestCode()
    {
        // Make AJAX call. Code returned.

        ***** How do I put the Code returned above into a field on my configuration screen?**
    }
</script>
<tabl开发者_C百科e>
    <tr>
        <td>
            <button style="" onclick="requestCode(); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
                <span><?php echo $this->escapeHtml($this->getButtonLabel()); ?></span>
            </button>
        </td>
    </tr>
</table>

My question is in the requestCode function, when I get the text returned from my web service, how do I put that text into a field on my configuration gui?

Thank you.


Doh, all I needed to do was document.getElementById('field_receiving_the_code').value=my_code;

0

精彩评论

暂无评论...
验证码 换一张
取 消