Php Magento 2-如何将phtml文件中的输入值传递给block类?

Php Magento 2-如何将phtml文件中的输入值传递给block类?,php,jquery,magento2,Php,Jquery,Magento2,我正试图用我的定制代码覆盖Magento模块块,包括phtml文件和块中的php类。在我的phtml文件中,我添加了一个输入字段,我希望将输入值传递给Block类,以便能够使用该值更新数据库 到目前为止,我已经创建了一个按钮和一个按钮调用的onClickphp函数,但我不知道如何将输入值传递给该函数。我试图使用文档.getElementById,但它不起作用 php函数是: public function updatePayment($paidAmount) { $currentPaid

我正试图用我的定制代码覆盖Magento模块块,包括phtml文件和块中的php类。在我的phtml文件中,我添加了一个输入字段,我希望将输入值传递给Block类,以便能够使用该值更新数据库

到目前为止,我已经创建了一个按钮和一个按钮调用的
onClick
php函数,但我不知道如何将输入值传递给该函数。我试图使用
文档.getElementById
,但它不起作用

php函数是:

public function updatePayment($paidAmount)
{
    $currentPaid = $this->getSource()->getTotalPaid();
    $this->getOrder()->setTotalPaid($paidAmount + $currentPaid)->save();
}
phtml文件输入HTML:

<input id="update-payment-input" type="text" style="text-align:right;" value="<?= $block->setDefaultAmountForPayment() ?>">
<script>
    require(['prototype'], function() {
        document.getElementById("update-payment-submit").addEventListener("click", updateAmount);
        function updateAmount() {
            <?= $block->updatePayment() ?>
            // Here I tried to use document.getElementById to get the input value
        }
    });
</script>

//在这里,我尝试使用document.getElementById获取输入值
}
});

我希望捕获值并将其传递给
Block
类中的函数,但它显示一个错误,表示文档未定义。

将此代码添加到HTML文件中

<input id="update-payment-input" type="text" style="text-align:right;" value="<?= $block->setDefaultAmountForPayment() ?>" onclick="updateAmount(this.value)">
<script>
    function updateAmount(value) {
        <?= $block->updatePayment(value) ?>
    }
</script>

这是相同的逻辑,我可以触发按钮,但我需要的是将输入值传递给函数,有什么想法吗?没有,它在