2

I am trying to understand Joomla's MVC logic. please help me figure out the processing of the task

Unedited code from a Joomla package has the front end article edit form with the task field, but its value is missing (file root/components/com_content/views/form/tmpl/edit.php ):

<input type="hidden" name="task" value="" />

By default, the URL of the form's action does not have a task parameter. This is how I see the URL for the action:

JRoute::_('index.php?option=com_content&a_id=' . (int) $this->item->id); ?>

I am not sure, but I think that when the flow reaches the component's entry point, in this case, file root/components/com_content/content.php, the input includes a task article.save

The input data I get is:

 ["data":protected]=>
  &array(13) {
    ["a_id"]=>
    string(1) "7"
    ["jform"]=>
    array(12) {
      ["title"]=>
      string(69) "Test 1"
      ["version_note"]=>
      string(0) ""
      ["state"]=>
      string(1) "1"
      ["publish_up"]=>
      string(19) "2018-05-23 05:37:29"
      ["publish_down"]=>
      string(0) ""
      ["tags"]=>
      array(3) {
        [0]=>
        string(1) "2"
        [1]=>
        string(1) "4"
        [2]=>
        string(1) "6"
      }
      ["metadesc"]=>
      string(0) ""
      ["metakey"]=>
      string(0) ""
      ["articletext"]=>
      string(181) "<p>TEST This is some text</p>
<p>Line 1</p>
<p>Line 2</p>
<p> </p>
<p>Line 3</p>
<p> </p>
<p>Line 7</p>"
      ["com_fields"]=>
      array(1) {
        ["testfield"]=>
        string(27) "<span class="star">@</span>"
      }
      ["catid"]=>
      string(1) "8"
      ["language"]=>
      string(1) "*"
    }
    ["task"]=>
    string(12) "article.save"
    ["return"]=>
    string(180) "aW5kZXgucGhwP29wdGlvbj1jb21fY29udGVudCZ0YXNrPWFydGljbGUuZWRpdCZhX2lkPTcmcmV0dXJuPWFIUjBjSE02THk5c2IyTmhiR2h2YzNRdmMyaHZjblJ6ZEc5eWVTNXpjR0ZqWlM5d2RXSnNhV05mYUhSdGJDOTBaWE4wTFRFPQ=="
    ["13456789"]=>
    string(1) "1"
    ["option"]=>
    string(11) "com_content"
    ["view"]=>
    string(8) "category"
    ["layout"]=>
    string(4) "blog"
    ["id"]=>
    string(1) "8"
    ["Itemid"]=>
    string(3) "101"
  }

Where is the task set?

Given the original edit.php file is missing a value for the task field, is there another field in this form that influences the setting of the task in a file that is called after I click the save button?

Like I try to communicate above, the component's input shows ["task"]=>string(12) "article.save" when the component's entry point file is called (i.e., root/components/com_content/content.php"

Given that the URL task parameter is missing from the form's action, does the URL from which I make the request influences the code that sets the task?

I welcome any information in helping to understand Joomla's MVC logic

1 Answer 1

2

If you inspect the button in the back end, you'll notice that for the most part they are <button onclick="Joomla.submitbutton('view.task');"></button>. When Joomla.submitbutton is called, the value passed into it is automatically transferred into <input type="hidden" name="task" /> if found inside of a <form> with the ID adminForm.

Otherwise, controllers automatically default all tasks to view.display if no task is given.

1
  • Yes; after I read your answer I noticed the button tag <button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('article.save')"> Thank you
    – IberoMedia
    Commented Nov 6, 2018 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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