I have several links on my page that should refer to a joomla contact form. I want to have automatically filled in email subjects to that contact form for each link. I tried to solve it with get params but with no success. This is the email subject text field I could extract from the html:

   <input type="text" aria-required="true" required="required" size="60" class="required" value="" id="jform_contact_emailmsg" name="jform[contact_subject]">

I tried to send post params like that, but it does not work:


Is this the right way? Are there any other easier solutions?

  • Is the extension handling the contact form view 3rd party or something you're custom developing? Jan 7, 2016 at 15:13
  • @Brian this is a input handling as a customHTML module
    – cilap
    Jan 7, 2016 at 20:00

1 Answer 1


My assumption with this answer is you are developing a component handling the contact form view.

The correct way to handle this would be in your Contact model. Technically, proper form in the MVC would require retrieving and santitizing URL params in the controllers, but for simplicity sake we'll focus on the model portion.

In the model overload the loadFormData method from the parent class. It is in here you can alter XML form definition field attributes and values.

 * Method to get the data that should be injected in the form.
 * @return  array  The default data is an empty array.
 * @since   1.6
protected function loadFormData()
 // Check the session for previously entered form data.
    $data = JFactory::getApplication()->getUserState('com_mycomponent.edit.contact.data', array());

    if (empty($data))
        $data = $this->getItem();

    // Load core JInput class to retrieve URL params
    $input = JFactory::getApplication()->input;

    // Add values for params to data if present
    $data->contact_emailmsg = $input->get('jform_contact_emailmsg', null, 'string');
    $data->contact_subject = $input->get('jform_contact_subject', null, 'string');

    return $data;   

A final note on how you are constructing the URLs. I noticed you have two variations for the same form field value, which I'm not sure you need. It appears you have really only need two links:


Hope that helps!

Your Answer

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

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