Reputation: 57
This maybe a question asked many times on Joomla forums, but after searching for some time, I did not find a good answer, instead of "its impossible" and "use a 3rd party form component". I want to add another field (phone number) on the default Joomla 2.5 contact form, so the user can send that info, along with his message. From what I've read, its said that is a Joomla limitation from his mail implementation, which can send only name, subject and message. I'm not a experienced Joomla developer, but from my limited knowledge, I belive this can be obtained in a simple way, just by adding fields in the template contact form and concatenate that fields with the message field (or at least that could solve my problem easily). Like I said, I'm not a experienced developer, so I can't figure out exactly how to do it (and preferably not breaking Joomla installation by modifying too much the core files, if thats the case). Anyone can help? Or at least point me in the right direction?
Thanks.
Upvotes: 2
Views: 9046
Reputation: 1873
You should never edit core files in Joomla, otherwise an update to those files could potentially bring your site down. The following link will get you started creating a user plugin where you can add/remove all the fields you need.
http://docs.joomla.org/Creating_a_profile_plugin
Upvotes: 2
Reputation: 11
If you want to add fields to contact us default form. You need to add fields in 4 files
1) /components/com_contact/controllers/contact.php`
$phone = $data['contact_phone'];
2) /components/com_contact/views/contact/tmpl/default_form.php
<dt><?php echo $this->form->getLabel('contact_phone'); ?></dt>
<dd><?php echo $this->form->getInput('contact_phone'); ?></dd>
3) /components/com_contact/models/forms/contact.xml
<field name="contact_phone"
type="phone"
id="contact-phone"
size="30"
description="COM_CONTACT_PHONE_DESC"
label="COM_CONTACT_PHONE_LABEL"
filter="integer"
required="false"
/>
4) templates/your template/html/com_contact/contact/default_form.php
<div>
<?php echo $this->form->getLabel('contact_phone'); ?>
<?php echo $this->form->getInput('contact_phone'); ?>
</div>
Thanks & Regards, Mithali
Upvotes: 0
Reputation: 11
Maybe a bit late and I hope you have solved your problem already.
But if not you can check out: Elin Warings tutorial for making a form plugin.
Or read about overrides for Joomla core functions:How to create a custom form field type.
Upvotes: 1
Reputation: 6770
You can make a plugin to add the field, it's not hard or you can use one of the many extensions available.
Upvotes: 0
Reputation: 19733
You're right, most people people say "use a 3rd party extension". However there is a very good reason for this. When using Joomla, it's not recommended to edit core files. "Why" you might ask. Purely because of the following reasons:
mysql_connect
rather than the Joomla database class.So to answer you're question (even though you may not want to hear this), I'm going to say use a 3rd party extension from this category:
http://extensions.joomla.org/extensions/contacts-and-feedback/contact-forms
There are a very big variety so simply see which one suits your needs.
Hope this gave you a good insight of things.
Upvotes: 2