I've my custom task = request.state
in my controller, I've code like
public function state($param)
{
//Do my task
}
My question is how do I pass $param to
Joomla.submitbutton(request.state)
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communityIn general you override Joomla.submitbutton in your view's php file, set a hidden fields value to the request parameter you wish to send, then finally submit the form.
So say your admin view's template has a field
<input type="hidden" id="myinfo" value="" >
Then you would add some JavaScript to the view's template:
<script type="text/javascript">
Joomla.submitbutton = function(task) {
jQuery('#myInfo').val('my custom value');
Joomla.submitform(task, jQuery('#adminForm'));
}
</script>
Then your request's $_POST array will have
[myInfo] => 'my custom value'
@Rob - Thank you very much for your help. However, your method did not work for me. Here's how I made it work:
In my view layout file (default.php):
I added one hidden state field with blank code:
<input type="hidden" name="state" value="" />
In my JS file I added following code:
$('#cancel-request').click(function () {
if (confirm("Are you sure?"))
{
$("input[name='state']").val('cancel');
Joomla.submitbutton('request.state');
}
else
{
return false;
}
}
In my controller, I added following code:
public function state()
{
$state = $this->input->post->get('state', '');
// based on $state I made my code.
}