Skip to content

Commit 87291fa

Browse files
v1.3 released.
v1.3 released with new features and improvements.
2 parents 421b7d2 + afe91e6 commit 87291fa

19 files changed

+300
-110
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@
22
![AUR](https://img.shields.io/aur/license/yaourt.svg)
33
[![GitHub release](https://img.shields.io/github/release/joomdev/JD-Simple-Contact-Form.svg)](https://github.com/joomdev/JD-Simple-Contact-Form/releases)
44

5+
# JD Simple Contact Form
6+
JD Simple Contact form extension is a simple form builder for the Joomla ideally suited for beginners and also meets the basic requirements for every developer and designer. It allows creating various types of form like the mailing list, survey, contact and more.
7+
<center><a target="_blank" href="https://www.joomdev.com/products/extensions/jd-simple-contact-form"><img src="https://www.joomdev.com/images/extensions/jd-simple-contact-form/banner.jpg" /></a></center>
8+
59
# Requirements
610
* Joomla: 3.8 +
711
* PHP : 5.6+
812

9-
# JD Simple Contact Form
10-
JD Simple Contact form extension is simple form builder for a Joomla ideally suited for beginners and also meets the basic requirements for every developers and designers. It allows to create various types of form like mailing list, survey, contact and more.
13+
## Here is what's included:
14+
- Unlimited number of form fields.
15+
- 10+ different field types.
16+
- Ability to make fields required with custom error messages.
17+
- Ability to order fields.
18+
- Ability to configure thank you message.
19+
- Ability to redirect to another page after form submission.
20+
- Custom email messages.
21+
- Ability to CC, BCC messages.
22+
- Ajax Submission.
1123

1224
# [Documentation](https://github.com/joomdev/JD-Simple-Contact-Form/wiki)

forms/fielditem.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
<option value="1">JYES</option>
4848
<option value="0">JNO</option>
4949
</field>
50+
<field
51+
showon="required:1"
52+
name="custom_error"
53+
type="text"
54+
label="MOD_JDSCF_CUSTOM_ERROR_LBL"
55+
description="MOD_JDSCF_CUSTOM_ERROR_DESC"
56+
/>
5057
<field
5158
name="show_label"
5259
type="radio"

helper.php

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ public static function submitForm($ajax = false) {
9595
if(is_array($value)) {
9696
if(isset($value['email'])) {
9797
$values[$name] = $value['email'];
98+
//multiple cc
9899
if(isset($value['cc']) && $value['cc'] == 1) {
99100
$cc_emails[] = $value['email'];
100101
}
102+
//single cc
103+
if(isset($value['single_cc']) && $value['single_cc'] == 1) {
104+
$cc_emails[] = $value['email'];
105+
}
101106
}
102107
} else {
103108
$values[$name] = $value;
@@ -121,8 +126,10 @@ public static function submitForm($ajax = false) {
121126
}
122127
}
123128

124-
if ($fld['type'] == 'checkbox') {
125-
$value = $_POST['jdscf'][$name]['cb'];
129+
if ($fld['type'] == 'checkbox') {
130+
if (isset($_POST['jdscf'][$name]['cb'])){
131+
$value = $_POST['jdscf'][$name]['cb'];
132+
}
126133
if (is_array($value)) {
127134
$value = implode(',', $value);
128135
} else {
@@ -208,6 +215,19 @@ public static function submitForm($ajax = false) {
208215
if (!empty($recipients)) {
209216
$mailer->addRecipient($recipients);
210217
}
218+
219+
// Reply-To
220+
if (!empty($params->get('reply_to', ''))) {
221+
$reply_to = $params->get('reply_to', '');
222+
$reply_to = self::renderVariables($contents, $reply_to);
223+
if (!filter_var($reply_to, FILTER_VALIDATE_EMAIL)) {
224+
$reply_to = '';
225+
}
226+
$mailer->addReplyTo($reply_to);
227+
} else {
228+
$reply_to = '';
229+
}
230+
211231
// CC
212232
$cc = !empty($params->get('email_cc', '')) ? $params->get('email_cc') : '';
213233
$cc = empty($cc) ? [] : explode(",", $cc);
@@ -233,6 +253,7 @@ public static function submitForm($ajax = false) {
233253
}
234254
if(!empty($errors)) {
235255
$app = JFactory::getApplication();
256+
$send = false;
236257
//showing all the validation errors
237258
foreach ($errors as $error) {
238259
$app->enqueueMessage(\JText::_($error), 'error');
@@ -243,7 +264,13 @@ public static function submitForm($ajax = false) {
243264
}
244265

245266
if ($send !== true) {
246-
throw new \Exception(JText::_('MOD_JDSCFEMAIL_SEND_ERROR'));
267+
switch($params->get('ajaxsubmit'))
268+
{
269+
case 0: throw new \Exception(JText::_('MOD_JDSCFEMAIL_SEND_ERROR'));
270+
break;
271+
case 1: throw new \Exception(json_encode($errors));
272+
break;
273+
}
247274
}
248275
$message = $params->get('thankyou_message', '');
249276
if (empty($message)) {
@@ -264,7 +291,7 @@ public static function submitForm($ajax = false) {
264291
}
265292
$app->redirect($return);
266293
}
267-
return ['message' => $message, 'redirect' => $redirect_url];
294+
return ['message' => $message, 'redirect' => $redirect_url, 'errors' => json_encode($errors)];
268295
}
269296

270297
public static function renderVariables($variables, $source) {
@@ -344,13 +371,25 @@ public static function getJS($moduleid) {
344371
return $GLOBALS['mod_jdscf_js_' . $moduleid];
345372
}
346373

347-
public static function isCCMail($field, $params){
374+
//for single email field (at bottom)
375+
public static function isSingleCCMail($params) {
376+
$singlesendcopy_email = $params->get('single_sendcopy_email', 0);
377+
$singlesendcopyemail_field = $params->get('singleSendCopyEmail_field', '');
378+
if($singlesendcopy_email && !empty($singlesendcopyemail_field)){
379+
return true;
380+
} else {
381+
return false;
382+
}
383+
}
384+
385+
//for multiple email fields
386+
public static function isCCMail($field, $params) {
348387
$sendcopy_email = $params->get('sendcopy_email', 0);
349388
$sendcopyemail_field = $params->get('sendcopyemail_field', '');
350389
$sendcopyemail_fields = explode(",", $sendcopyemail_field);
351390
if($sendcopy_email && !empty($sendcopyemail_fields) && in_array($field->name, $sendcopyemail_fields)){
352391
return true;
353-
}else{
392+
} else {
354393
return false;
355394
}
356395
}
@@ -373,17 +412,17 @@ public static function uploadFile($name, $src) {
373412
else
374413
{
375414
$tmppath = JPATH_SITE . '/tmp';
376-
if(!file_exists($tmppath.'/jdscf')){
415+
if (!file_exists($tmppath.'/jdscf')) {
377416
mkdir($tmppath.'/jdscf',0777);
378417
}
379418
$folder = md5(time().'-'.$filename.rand(0,99999));
380-
if(!file_exists($tmppath.'/jdscf/'.$folder)){
419+
if (!file_exists($tmppath.'/jdscf/'.$folder)) {
381420
mkdir($tmppath.'/jdscf/'.$folder,0777);
382421
}
383422
$dest = $tmppath.'/jdscf/'.$folder.'/'.$filename;
384423

385424
$return = null;
386-
if (JFile::upload($src, $dest)){
425+
if (JFile::upload($src, $dest)) {
387426
$return = $dest;
388427
}
389428
return $return;

language/en-GB/en-GB.mod_jdsimplecontactform.ini

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ MOD_JDSIMPLECONTACTFORM_XML_DESCRIPTION="JD Simple Contact form provides you wit
88
Here is what's included:
99
<ul>
1010
<li>Unlimited number of form fields.</li>
11-
<li>9 different field types.</li>
12-
<li>Ability to make fields required.</li>
11+
<li>10+ different field types.</li>
12+
<li>Ability to make fields required with custom error messages.</li>
1313
<li>Ability to order fields.</li>
1414
<li>Ability to configure thank you message.</li>
1515
<li>Ability to redirect to another page after form submission.</li>
1616
<li>Custom email messages.</li>
17-
<li>Ability to CC, BCC messages.</li>
17+
<li>Ability to CC, BCC, Reply-To messages.</li>
1818
<li>Ajax Submission.</li>
1919
</ul>"
2020

@@ -48,19 +48,25 @@ MOD_JDSCF_SHOW_LABEL_DESC="Select to display the label before the field."
4848
MOD_JDSCF_OPTIONS_LAYOUT_LBL="Options Layout"
4949
MOD_JDSCF_OPTIONS_LAYOUT_DESC="Select to display checkboxes and radios in vertically or stacked layout."
5050

51-
MOD_JDSCF_FORM_SUBMIT_LBL="Submit button text"
51+
MOD_JDSCF_FORM_SUBMIT_LBL="Submit Button Text"
5252
MOD_JDSCF_FORM_SUBMIT_DESC="Enter to change text for the submit button. Default is <b>Submit</b>."
5353
MOD_JDSCF_FORM_SUBMIT_DEFAULT="Submit"
5454

5555
MOD_JDSCF_REQUIRED_LBL="Required"
5656
MOD_JDSCF_REQUIRED_DESC="Select to make the input of the field required."
5757

58+
MOD_JDSCF_CUSTOM_ERROR_LBL="Custom Required Error"
59+
MOD_JDSCF_CUSTOM_ERROR_DESC="Enter to show a custom error message when fields are required."
60+
5861
MOD_JDSCF_TYPE_LBL="Type"
5962
MOD_JDSCF_TYPE_DESC="Select the type of the field."
6063

6164
MOD_JDSCF_WIDTH_LBL="Width"
6265
MOD_JDSCF_WIDTH_DESC="Select a width between 2 - 12, This is based on bootstrap grid system, More info at <a href="https://getbootstrap.com/docs/">https://getbootstrap.com/docs/</a>."
6366

67+
MOD_JDSCF_SUBMIT_WIDTH_LBL="Submit Button Width"
68+
MOD_JDSCF_SUBMIT_WIDTH_DESC="Select a width between 2 - 12, This is based on bootstrap grid system, More info at <a href="https://getbootstrap.com/docs/">https://getbootstrap.com/docs/</a>."
69+
6470
MOD_JDSCF_PLACEHOLDER_LBL="Placeholder"
6571
MOD_JDSCF_PLACEHOLDER_DESC="Enter to add placeholder on this input."
6672

@@ -77,10 +83,10 @@ MOD_JDSCF_TYPE_CALENDAR_LBL="Calendar"
7783
MOD_JDSCF_TYPE_LIST_LBL="List"
7884

7985
MOD_JDSCF_OPTIONS_LBL="Options"
80-
MOD_JDSCF_OPTIONS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum."
86+
MOD_JDSCF_OPTIONS_DESC="Enter return seperated values."
8187

8288
MOD_JDSCF_CSS_LBL="Load CSS"
83-
MOD_JDSCF_CSS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum."
89+
MOD_JDSCF_CSS_DESC=""
8490

8591

8692
MOD_JDSCF_REQUIRED_ERROR="%s is required."
@@ -114,6 +120,9 @@ MOD_JDSCF_EMAIL_SUBJECT_DESC="Subject of the email (<b>You can use {field:label}
114120
MOD_JDSCF_EMAIL_TO_LBL="Email Address"
115121
MOD_JDSCF_EMAIL_TO_DESC="Enter the email address to recieve submissions. Use comma to seperate multiple emails."
116122

123+
MOD_JDSCF_REPLY_TO_LBL="Reply-to Email"
124+
MOD_JDSCF_REPLY_TO_DESC="Enter the Reply-to email address"
125+
117126
MOD_JDSCF_EMAIL_CC_LBL="CC Email"
118127
MOD_JDSCF_EMAIL_CC_DESC="CC email address to recieve submissions. Use comma to seperate multiple emails."
119128

@@ -123,10 +132,17 @@ MOD_JDSCF_EMAIL_BCC_DESC="BCC email address to recieve submissions. Use comma to
123132
MOD_JDSCF_EMAIL_TEMPLATE_LBL="Email Template"
124133
MOD_JDSCF_EMAIL_TEMPLATE_DESC="Select the email template, The <b>default</b> template lists all fields in the order they exist in <br><b>{field:label}: {field:value}</b></br> format."
125134

126-
MOD_JDSCF_SEND_COPY="Send Copy of Email"
127-
MOD_JDSCF_SEND_COPY_LBL_TITLE="Send me a copy"
128-
MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkbox for users to send a copy of email to themselves."
135+
; Single Email Fields
136+
MOD_JDSCF_SINGLE_SEND_COPY="Send Copy of Email (Single)"
137+
MOD_JDSCF_SINGLE_SEND_COPY_LBL_TITLE="Send me a copy"
138+
MOD_JDSCF_SINGLE_SEND_COPY_DESCRIPTION="Displays a checkbox on bottom for users to send a copy of email to themselves."
139+
MOD_JDSCF_SINGLE_SEND_COPY_EMAIL_FIELD="Enter Single Email Field Name"
140+
MOD_JDSCF_SINGLE_SEND_COPY_LABEL="Enter Send Copy Label"
129141

142+
; Multiple Email Fields
143+
MOD_JDSCF_SEND_COPY="Send Copy of Email (Multiple)"
144+
MOD_JDSCF_SEND_COPY_LBL_TITLE="Send me a copy"
145+
MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkboxes for users to send a copy of email to themselves under Email Fields."
130146
MOD_JDSCF_SEND_COPY_EMAIL_FIELD="Enter Email Field Name"
131147
MOD_JDSCF_SEND_COPY_LABEL="Enter Send Copy Label"
132148

@@ -142,7 +158,7 @@ MOD_JDSCF_THANKYOU_MESSAGE_DESC="Enter a Thank you message to be displayed after
142158
MOD_JDSCF_REDIRECT_LBL="Redirect URL"
143159
MOD_JDSCF_REDIRECT_DESC="Enter a URL to redirect users after submission. Leave blank to if not required. (<b>You can use {field:label} & {field:value} to render dynamic values in this field</b>)"
144160

145-
MOD_JDSCF_SUBMITBTN_CLASS_LBL="Submit button class"
161+
MOD_JDSCF_SUBMITBTN_CLASS_LBL="Submit Button Class"
146162
MOD_JDSCF_SUBMITBTN_CLASS_DESC=""
147163

148164
MOD_JDSCF_UNSUPPORTED_FILE_ERROR="Unsupported Filetype"

language/en-GB/en-GB.mod_jdsimplecontactform.sys.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ MOD_JDSIMPLECONTACTFORM_XML_DESCRIPTION="JD Simple Contact form provides you wit
33
Here is what's included:
44
<ul>
55
<li>Unlimited number of form fields.</li>
6-
<li>9 different field types.</li>
7-
<li>Ability to make fields required.</li>
6+
<li>10+ different field types.</li>
7+
<li>Ability to make fields required with custom error messages.</li>
88
<li>Ability to order fields.</li>
99
<li>Ability to configure thank you message.</li>
1010
<li>Ability to redirect to another page after form submission.</li>
1111
<li>Custom email messages.</li>
12-
<li>Ability to CC, BCC messages.</li>
12+
<li>Ability to CC, BCC, Reply-To messages.</li>
1313
<li>Ajax Submission.</li>
1414
</ul>
1515
"

layouts/emails/default.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
138138
<tr>
139139
<td class="content-block powered-by" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center">
140-
Powered by <a href="https://www.joomdev.com/products/extensions/jd-simplecontactform" style="color: #999999; font-size: 12px; text-align: center; text-decoration: none;"><?php echo JText::_('MOD_JDSIMPLECONTACTFORM'); ?></a>.
140+
Powered by <a href="https://www.joomdev.com/products/extensions/jd-simple-contact-form" style="color: #999999; font-size: 12px; text-align: center; text-decoration: none;"><?php echo JText::_('MOD_JDSIMPLECONTACTFORM'); ?></a>.
141141
</td>
142142
</tr>
143143
</table>

layouts/fields/calendar.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,29 @@
1010
extract($displayData);
1111
$attrs = [];
1212
if (isset($field->placeholder) && !empty($field->placeholder)) {
13-
$attrs[] = 'placeholder="' . $field->placeholder . '"';
13+
$attrs[] = 'placeholder="' . $field->placeholder . '"';
1414
}
1515

1616
if (!empty($field->id)) {
17-
$attrs[] = 'id="' . $field->id . '"';
17+
$attrs[] = 'id="' . $field->id . '"';
1818
}
1919

2020
if ($field->required) {
21-
$attrs[] = 'required';
22-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
21+
$attrs[] = 'required';
22+
if (!empty(trim($field->custom_error))) {
23+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
24+
} else {
25+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
26+
}
2327
}
2428

2529
$document = JFactory::getDocument();
2630
$style = 'label.calendar_icon {'
27-
. 'display: inherit;'
28-
. 'cursor: pointer;'
29-
. 'margin: 0px;'
30-
. 'border-radius: 0;'
31-
. '}';
31+
. 'display: inherit;'
32+
. 'cursor: pointer;'
33+
. 'margin: 0px;'
34+
. 'border-radius: 0;'
35+
. '}';
3236
$document->addStyleDeclaration($style);
3337
?>
3438

@@ -45,17 +49,17 @@
4549

4650
<?php
4751
$js = 'var jdscf_picker_' . $module->id . ' = new Pikaday({'
48-
. 'field: document.getElementById("' . $field->id . '")';
52+
. 'field: document.getElementById("' . $field->id . '")';
4953
if (isset($field->calendar_min) && !empty($field->calendar_min) && $field->calendar_min != '0000-00-00 00:00:00') {
50-
$js .= ',minDate: moment("' . $field->calendar_min . '").toDate()';
54+
$js .= ',minDate: moment("' . $field->calendar_min . '").toDate()';
5155
}
5256
if (isset($field->calendar_max) && !empty($field->calendar_max) && $field->calendar_max != '0000-00-00 00:00:00') {
53-
$js .= ',maxDate: moment("' . $field->calendar_max . '").toDate()';
57+
$js .= ',maxDate: moment("' . $field->calendar_max . '").toDate()';
5458
}
5559
if (isset($field->calendar_format) && !empty($field->calendar_format)) {
56-
$js .= ',format: "' . $field->calendar_format . '"';
60+
$js .= ',format: "' . $field->calendar_format . '"';
5761
} else {
58-
$js .= ',format: "MM-DD-YYYY"';
62+
$js .= ',format: "MM-DD-YYYY"';
5963
}
6064

6165
$js .= ',defaultDate: moment("' . date('Y-m-d') . '").toDate(),setDefaultDate:true';

layouts/fields/checkbox.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
extract($displayData);
1111
$options = ModJDSimpleContactFormHelper::getOptions($field->options);
1212
$attrs = [];
13+
1314
if ($field->required) {
14-
$attrs[] = 'required';
15-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
15+
$attrs[] = 'required';
16+
if (!empty(trim($field->custom_error))) {
17+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
18+
} else {
19+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
20+
}
1621
}
1722
?>
1823
<div class="form-check form-check-inline">

layouts/fields/checkboxes.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
$attrs = [];
1313
if ($field->required) {
1414
$attrs[] = 'required';
15-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
15+
if (!empty(trim($field->custom_error))) {
16+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
17+
} else {
18+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
19+
}
1620
}
1721
$optionslayout = isset($field->optionslayout) ? $field->optionslayout : 'vertical';
1822
?>

0 commit comments

Comments
 (0)