I have a Zend view in PHP with a form:
<form action="https://example.com/checkout/" name="info" method="post">
<div id="payment">
<div id="paypal>
<?php $this->is_paypal_payment = true; ?>
</div>
<div id="credit_card>
<?php $this->is_paypal_payment = false; ?>
</div>
</div>
</form>
When a user clicks the submit button, how can I set the instance variable in the Controller?
This is what I tried which didn’t work.
Controller:
$this->view->payment_option_paypal = false; // initialized value
$payment_method_option = $this->_getParam('payment_option_paypal', null);
if (!is_null($payment_method_option)) {
if ($payment_method_option == 'paypal') {
$this->_is_paypal = true;
}
}
View:
<div id="paypal" style="display: none;">
<?php $this->payment_option_paypal = "paypal"; ?>
<img src="paypal.gif" style="margin-right:20px;">
</div>
After clicking submit, the _getParam() function doesn’t capture the string “paypal” that the view set for instance variable in Controller $this->payment_option_paypal
Any ideas what’s wrong and how to go about this?
in you phtml page you have to use like this
and the controller
I hope it helps you and if you have any problem in my answer then let me know.