2

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)
| improve this question | | | | |
3

In 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'
| improve this answer | | | | |
2

@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.
}
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.