<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Adminhtml_Block_Widget_Grid_Serializer $this */
?>
<?php $_id = 'id_' . md5(microtime()) ?>
<?php $formId = $this->getFormId()?>
<?php if (!empty($formId)) :?>
<script type="text/javascript">
    Event.observe(window, "load", function(){
        var serializeInput  = document.createElement('input');
        serializeInput.type = 'hidden';
        serializeInput.name = '<?= $this->getInputElementName() ?>';
        serializeInput.id   = '<?= $_id ?>';
        try {
            document.getElementById('<?= $formId ?>').appendChild(serializeInput);
            new serializerController('<?= $_id?>', <?= $this->getDataAsJSON() ?>, <?= $this->getColumnInputNames(true) ?>, <?= $this->getGridBlock()->getJsObjectName() ?>, '<?= $this->getReloadParamName() ?>');
        } catch(e) {
            //Error add serializer
        }
    });
</script>
<?php else: ?>
<input type="hidden" name="<?= $this->getInputElementName() ?>"  value="" id="<?= $_id ?>" />
<script type="text/javascript">
    new serializerController('<?= $_id?>', <?= $this->getDataAsJSON() ?>, <?= $this->getColumnInputNames(true) ?>, <?= $this->getGridBlock()->getJsObjectName() ?>, '<?= $this->getReloadParamName() ?>');
</script>
<?php endif ?>

