1

I have been using Joomla for the last couple weeks and it seems straightforward so far and I understand the code in examples. I've successfully created a custom module that displays on the front end.

Now I am trying to develop a custom component which is a lot harder. Basically it takes a form from the front end and I want to do something with that sent data on the backend. I will probable save to the database but for the moment I just want to retrieve that data and perhaps save the data to a text file.

Say I have a form like this on the front end view which is created by my component...

<form action="<?php echo JRoute::_('index.php?option=com_example&task=file.submit'); ?>" enctype="multipart/form-data" method="post">
    <input type="file" name="jform1[test][]" />
    <input type="file" name="jform1[test][]" />
    <input type="submit" value="submit" />
</form>

...where does this form post to? Will it go to the site controller or admin controller?

I need to the data to go to the admin controller as there are options in there that are needed later to do something with the data (I plan to use cURL and send the data off somewhere else)

1

"file" is the frontend controller called here.

/components/com_your_component/controllers/file.php

class Your_ComponentControllerFile extends JControllerLegacy
{
    public function submit(){

      // do something

    }

}

You can load admin controllers and helpers within this controller.

Please consider this too: https://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms

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.