5

I work mainly in overrides as much as possible, so am using /templates/.../html/com_contact/contact/default_form.php

I know I can just remove the code that shows the subject line:

<div class="control-group">
    <div class="control-label"><?php echo $this->form->getLabel('contact_subject'); ?></div>
    <div class="controls"><?php echo $this->form->getInput('contact_subject'); ?></div>
</div>

But the problem is that when the form is filled out, the validation to check the subject line is still there.

Removing this, would require a core hack, but is there anyway to do it using overrides? Or safely, so that it won't revert when updated?

I'd like to keep to using com_contact wherever possible, to limit the amount of plugins running on my installation.

1 Answer 1

2

The subject field is set to be required by the XML file that the contact form consists of. You can see this by going here:

components/com_contact/models/forms/contact.xml

Then line ~ 23:

<field name="contact_subject"
    type="text"
    id="contact-emailmsg"
    size="60"
    description="COM_CONTACT_CONTACT_MESSAGE_SUBJECT_DESC"
    label="COM_CONTACT_CONTACT_MESSAGE_SUBJECT_LABEL"
    filter="string"
    validate="contactemailsubject"
    required="true"
/>

What you probably need is to override this XML file. FYI: You can find a similar question here: Overriding Core Components Model Form XML

The easiest and less hassle way to achieve this is by using the Form XML Overrides Plugin.

With the plugin installed and enabled, you can create a copy of the contact.xml file and place it in: templates/system/forms/com_contact/contact.xml

***** The Forms folder you will need to create it.

Remove the required="true" from the subject field, or remove the subject field completely. Also remove the call to the field from your template override file, as you described in your question.

Then in the plugin administration page, you need to specify the component that you want to override for the site.

Plugin Help Page

1
  • That's absolutely awesome, thanks for the answer! Although it uses a plugin, it definitely solves the issue of future updates!
    – user1889
    Commented Sep 12, 2014 at 10:30

Your Answer

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