Category: Simple Email Form Tips
Hits: 4528


The module provides a total of 8 fields, however 2 of them, "From" and "Subject" are required.  This leaves only 6 fields left.  What if I want to add more fields?


Two source code files need to be modified.  Locate them in /path/to/joomla/modules/mod_simpleemailform.

1. Modify helper.php as follows:

Increase the maximum from 8 to the new target.  For example, if you want to add one more field, change this value to 9:
// locate the line below and change the value for $_maxFields:
protected $_maxFields = 9;  // mixed From, Subject, text, textarea, etc.

2. Modify mod_simpleemailform.xml

You will need to add an extra block under "Basic Options" with all the parameters for the new field.  Make sure you change the number to reflect the new field. 

Using the example above, let's say you're adding a new field 9.  You would need to copy the parameters for block 8, and paste them back in, changing the field number from 8 to 9:

<field name="mod_simpleemailform_field9active" type="radio" default="N" label="Activate Field 9" description="Select 'Y' if you want to activate Field 9 and 'R' to activate and make it required. Enter 'H' to make the field hidden (appears in email automatically)" >
                    <option value="Y">JYES</option>
                    <option value="N">JNO</option>
                    <option value="R">Required</option>
                    <option value="H">Hidden</option>
                <field name="mod_simpleemailform_field9label" type="text" size="40" default="Field 9" label="Label for Field 9" description="The label for the 5th optional field which will appear in your email form" />
                <field name="mod_simpleemailform_field9value" type="text" size="40" default="Value 9"  label="Default Value for Field 9" description="Enter the default value for this field, or hit the spacebar for no default. If this field is a drop-down select, radio button, or checkbox field, enter options separated by commas as follows: return1=visible1,return2=visible2 (where 'returnX' = value returned when selected and 'visibleX' = what is visible onscreen." />
                <field name="mod_simpleemailform_field9size" type="text" size="4" default="40" label="Display Size of Field 9" description="The size of the 5th optional field which will appear in your email form.  If textarea, enter value as n,n (rows,cols).  If field is Radio / Checkbox size is width in pixels.  Set to 0 to suppress this width, which allows the CSS class to determine appearance." />
                <field name="mod_simpleemailform_field9maxx" type="text" size="4" default="255" label="Maximum Length of Field 9" description="The maximum number of characters allowed in this field" />
                <field name="mod_simpleemailform_field9from" type="list" default="N" label="Field Type" description="Select 'From' if you want this field to be the 'From' text field, 'Subject' if you want this to be the subject text field, 'Normal' for a normal text field, 'Textarea' for a textarea (i.e. a box), and 'Drop' for a drop-down select box." >
                    <option value="F">From</option>
                    <option value="S">Subject</option>
                    <option value="N">Normal</option>
                    <option value="A">Textarea</option>
                    <option value="D">Drop</option>
                    <option value="R">Radio</option>
                    <option value="C">Checkbox</option>
                <field name="mod_simpleemailform_field9ckRfmt" type="radio" default="C" label="Field 9 Format" description="If field is radio buttons or checkboxes, enter the Format.  Horizontal format is table/row/col/col/col; Vertical format is table/row/col/col/row/col/col. Use CSS (default) assumes you will use CSS." >
                    <option value="H">Horizontal</option>
                    <option value="V">Vertical</option>
                    <option value="C">Use CSS</option>
                <field name="mod_simpleemailform_field9ckRpos" type="radio" default="B" label="Field 9 Before/After" description="If field is radio buttons or checkboxes, is label Before or After?" >
                    <option value="B">Before</option>
                    <option value="A">After</option>

3. You can then select "Extensions" and manage the module.  Just change the parameters for the new field as desired. 

That's it!

Thanks to Rolph Lieverse for testing this!