When redirecting *
means current, so with $this->_redirect('*/*');
you are targeting the current module, current controller and index action. As I see a closing ?>
in your controller (which by the way you should exclude, see here) I'm going to assume you have no more actions in that controller, including the index action, therefore the redirect fails in a 404 because the action does not actually exist.
You need to redirect to the adminhtml module, sales_order controller and view action instead so use the following:
$this->_redirect('adminhtml/sales_order/view', array('order_id' => $someorderid));
With this code you create this block and render it immediately, without adding it to the layout hierarchy. That means it doesn't have access to the parent block because there is no parent.
To create a block dynamically as child of the current block, use:
$child = $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Namespace_Module::state.phtml");
$this->addChild('state', $child);
And to render it:
echo $this->getChildHtml('state');
(I used "state" as alias here, but it can be anything else)
Now you have access to the parent from your state.phtml template, using $this->getParentBlock()
If I set state.phtml
in country.phtml
like
<?php
echo $this->getLayout()->createBlock("Namespace\Module\Block\Country")->setTemplate("Namespace_Module::state.phtml")->toHtml();
?>
Then Is it possible to call functions of Country.php
in
State.phtml
file ?
If you insist, you can do it like this:
echo $this->getLayout()
->createBlock("Namespace\Module\Block\Country")
->setTemplate("Namespace_Module::state.phtml")
->setData('country_block', $this)
->toHtml();
And then, in state.phtml
:
$this->getData('country_block')->METHOD_OF_COUNTRY_BLOCK();
Best Answer
if you are doing it with ajax,then Try this,
The above code can help you to pass params as post to any controller.
or
instead using jquery you can getting value of an element with simple javascript as,
var name = document.getElementById('input_field_id').value;