Adding more fields

25 Jul 2011 16:11 - 15 Sep 2014 03:55 #1 by Demis [Fox-Labs]
Adding more fields was created by Demis [Fox-Labs]

The following information applies to foxcontact 2.0 and newer versions, and won't work on foxcontact 1.8 and earlier. I know this is not an easy way to add fields, but currently is the only way. It will be easier in future versions.

You can add more fields in your form by editing a single file.

If you use the component, edit components/com_foxcontact/views/foxcontact/default.xml
If you use the module, edit modules/mod_foxcontact/mod_foxcontact.xml
If you are in doubt, edit both: it doesn't hurt!

Let's say you want to add a text field.
Add a new text field section immediately after the last one (it should be text9), increasing by one the numeration, so that the new section is called text10. If you copy and paste from section #9, be sure to change values text10display and text10order too.
<field name="text10" type="text" label="COM_FOXCONTACT_FIELDNAME_LBL" description="COM_FOXCONTACT_FIELDNAME_DSC" size="26" />
<field name="text10display" type="list" label="COM_FOXCONTACT_FIELD_STATE" description="JFIELD_ENABLED_DESC" default="0">
<option value="0">JDISABLED</option>
<option value="1">JOPTION_OPTIONAL</option>
<option value="2">JOPTION_REQUIRED</option>
<field name="text10order" type="text" label="JFIELD_ORDERING_LABEL" description="" size="5" default="0"/>
<field type="spacer" />

You can not add any kind of fields. This feature is limited to:
  1. text fields (as in the example)
  2. dropdown lists (select lists)
  3. textarea fields
  4. checkboxes
  5. Calendar fields

Upgrading (or re-installing) FoxContact

The .xml files will be overwritten, and any changes you have made will be lost.
You could save these files, and restore them after an upgrade/re-install.
However, there is a small chance that an upgrade might modify those files, in which case you would lose any new fields.

BUT - If, after upgrading/re-installing, you add your additional fields back in to the .xml files before you access the form in the backend (form administration), then they will remain in the form.

Please Log in or Create an account to join the conversation.