From b2b65885e6cfe61b3f3b11920e8b8d305138f280 Mon Sep 17 00:00:00 2001 From: Chandan Deep Date: Tue, 26 Feb 2019 19:24:43 +0530 Subject: [PATCH 01/14] header class added --- tmpl/default.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tmpl/default.php b/tmpl/default.php index ed27f0f..e45bdd8 100644 --- a/tmpl/default.php +++ b/tmpl/default.php @@ -24,12 +24,14 @@
- -
- - -

- +
+ +
+ + +

+ +
Date: Thu, 28 Feb 2019 17:22:05 +0530 Subject: [PATCH 02/14] Added CC functinality @ bottom Added single CC functionality and some little URL fixes and formatting. --- helper.php | 21 +++++++- .../en-GB/en-GB.mod_jdsimplecontactform.ini | 13 +++-- layouts/emails/default.php | 2 +- layouts/fields/singlecc.php | 14 +++++ layouts/fields/text.php | 2 +- mod_jdsimplecontactform.xml | 52 +++++++++++++++---- tmpl/default.php | 16 +++++- 7 files changed, 103 insertions(+), 17 deletions(-) create mode 100644 layouts/fields/singlecc.php diff --git a/helper.php b/helper.php index 1662d64..7d4f0e8 100644 --- a/helper.php +++ b/helper.php @@ -95,9 +95,14 @@ public static function submitForm($ajax = false) { if(is_array($value)) { if(isset($value['email'])) { $values[$name] = $value['email']; + //multiple cc if(isset($value['cc']) && $value['cc'] == 1) { $cc_emails[] = $value['email']; } + //single cc + if(isset($value['single_cc']) && $value['single_cc'] == 1) { + $cc_emails[] = $value['email']; + } } } else { $values[$name] = $value; @@ -344,13 +349,25 @@ public static function getJS($moduleid) { return $GLOBALS['mod_jdscf_js_' . $moduleid]; } - public static function isCCMail($field, $params){ + //for single email field (at bottom) + public static function isSingleCCMail($params) { + $singlesendcopy_email = $params->get('single_sendcopy_email', 0); + $singlesendcopyemail_field = $params->get('singleSendCopyEmail_field', ''); + if($singlesendcopy_email && !empty($singlesendcopyemail_field)){ + return true; + } else { + return false; + } + } + + //for multiple email fields + public static function isCCMail($field, $params) { $sendcopy_email = $params->get('sendcopy_email', 0); $sendcopyemail_field = $params->get('sendcopyemail_field', ''); $sendcopyemail_fields = explode(",", $sendcopyemail_field); if($sendcopy_email && !empty($sendcopyemail_fields) && in_array($field->name, $sendcopyemail_fields)){ return true; - }else{ + } else { return false; } } diff --git a/language/en-GB/en-GB.mod_jdsimplecontactform.ini b/language/en-GB/en-GB.mod_jdsimplecontactform.ini index 52aa2bc..5d98dee 100644 --- a/language/en-GB/en-GB.mod_jdsimplecontactform.ini +++ b/language/en-GB/en-GB.mod_jdsimplecontactform.ini @@ -123,10 +123,17 @@ MOD_JDSCF_EMAIL_BCC_DESC="BCC email address to recieve submissions. Use comma to MOD_JDSCF_EMAIL_TEMPLATE_LBL="Email Template" MOD_JDSCF_EMAIL_TEMPLATE_DESC="Select the email template, The default template lists all fields in the order they exist in
{field:label}: {field:value}
format." -MOD_JDSCF_SEND_COPY="Send Copy of Email" +; Single Email Fields +MOD_JDSCF_SINGLE_SEND_COPY="Send Copy of Email (Single)" +MOD_JDSCF_SINGLE_SEND_COPY_LBL_TITLE="Send me a copy" +MOD_JDSCF_SINGLE_SEND_COPY_DESCRIPTION="Displays a checkbox on bottom for users to send a copy of email to themselves." +MOD_JDSCF_SINGLE_SEND_COPY_EMAIL_FIELD="Enter Single Email Field Name" +MOD_JDSCF_SINGLE_SEND_COPY_LABEL="Enter Send Copy Label" + +; Multiple Email Fields +MOD_JDSCF_SEND_COPY="Send Copy of Email (Multiple)" MOD_JDSCF_SEND_COPY_LBL_TITLE="Send me a copy" -MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkbox for users to send a copy of email to themselves." - +MOD_JDSCF_SEND_COPY_DESCRIPTION="Displays a checkboxes for users to send a copy of email to themselves under Email Fields." MOD_JDSCF_SEND_COPY_EMAIL_FIELD="Enter Email Field Name" MOD_JDSCF_SEND_COPY_LABEL="Enter Send Copy Label" diff --git a/layouts/emails/default.php b/layouts/emails/default.php index 81d1a74..dd1ca39 100644 --- a/layouts/emails/default.php +++ b/layouts/emails/default.php @@ -137,7 +137,7 @@
- Powered by . + Powered by .
diff --git a/layouts/fields/singlecc.php b/layouts/fields/singlecc.php new file mode 100644 index 0000000..df0b9e7 --- /dev/null +++ b/layouts/fields/singlecc.php @@ -0,0 +1,14 @@ +get('singleSendCopyEmail_field', ''); +$singleCCTitle = $params->get('singleSendCopyEmailField_title', 'MOD_JDSCF_SINGLE_SEND_COPY_LBL_TITLE'); +?> + \ No newline at end of file diff --git a/layouts/fields/text.php b/layouts/fields/text.php index 2c9555a..9de0a12 100644 --- a/layouts/fields/text.php +++ b/layouts/fields/text.php @@ -52,7 +52,7 @@ ?> /> type == 'email' && $isCCMail){ ?> +if($field->type == 'email' && $isCCMail) { ?> \ No newline at end of file diff --git a/mod_jdsimplecontactform.xml b/mod_jdsimplecontactform.xml index d6a4cae..58787fb 100644 --- a/mod_jdsimplecontactform.xml +++ b/mod_jdsimplecontactform.xml @@ -144,6 +144,48 @@ + + + + + + + + + + + + + - +
get('jdscf-message-' . $module->id, ''); $captcha = $params->get('captcha', 0); +//checking if single cc is enabled +$single_cc_enable = ModJDSimpleContactFormHelper::isSingleCCMail($params); ?> index.php?option=com_ajax&module=jdsimplecontactform&format=json&method=submit" data-parsley-validate data-parsley-errors-wrapper="
    " data-parsley-error-class="border-danger" data-parsley-success-class="border-success" id="simple-contact-form-id; ?>" enctype="multipart/form-data">
    @@ -67,6 +69,18 @@ } ?> +
    +
    +
    + render(['params' => $params]); + } ?> +
    +
    +
    +
    Date: Fri, 1 Mar 2019 13:00:10 +0530 Subject: [PATCH 03/14] Changed Email template position --- mod_jdsimplecontactform.xml | 47 ++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/mod_jdsimplecontactform.xml b/mod_jdsimplecontactform.xml index 58787fb..0901476 100644 --- a/mod_jdsimplecontactform.xml +++ b/mod_jdsimplecontactform.xml @@ -133,27 +133,6 @@ label="MOD_JDSCF_EMAIL_BCC_LBL" description="MOD_JDSCF_EMAIL_BCC_DESC" /> - - - - - - Yes - - - Yes - - - + + + + +
    Date: Tue, 5 Mar 2019 12:26:11 +0530 Subject: [PATCH 04/14] Added: Reply-to field Now user can add one or more reply-to emails. --- helper.php | 8 ++++++++ language/en-GB/en-GB.mod_jdsimplecontactform.ini | 3 +++ mod_jdsimplecontactform.xml | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/helper.php b/helper.php index 7d4f0e8..8dab2b9 100644 --- a/helper.php +++ b/helper.php @@ -213,6 +213,14 @@ public static function submitForm($ajax = false) { if (!empty($recipients)) { $mailer->addRecipient($recipients); } + + // Reply-To + $reply_to = !empty($params->get('reply_to', '')) ? $params->get('reply_to') : ''; + $reply_to = explode(',', $reply_to); + if (!empty($reply_to)) { + $mailer->addReplyTo($reply_to); + } + // CC $cc = !empty($params->get('email_cc', '')) ? $params->get('email_cc') : ''; $cc = empty($cc) ? [] : explode(",", $cc); diff --git a/language/en-GB/en-GB.mod_jdsimplecontactform.ini b/language/en-GB/en-GB.mod_jdsimplecontactform.ini index 5d98dee..9ad085b 100644 --- a/language/en-GB/en-GB.mod_jdsimplecontactform.ini +++ b/language/en-GB/en-GB.mod_jdsimplecontactform.ini @@ -114,6 +114,9 @@ MOD_JDSCF_EMAIL_SUBJECT_DESC="Subject of the email (You can use {field:label} MOD_JDSCF_EMAIL_TO_LBL="Email Address" MOD_JDSCF_EMAIL_TO_DESC="Enter the email address to recieve submissions. Use comma to seperate multiple emails." +MOD_JDSCF_REPLY_TO_LBL="Reply-to Email" +MOD_JDSCF_REPLY_TO_DESC="Enter the email Reply-to email address" + MOD_JDSCF_EMAIL_CC_LBL="CC Email" MOD_JDSCF_EMAIL_CC_DESC="CC email address to recieve submissions. Use comma to seperate multiple emails." diff --git a/mod_jdsimplecontactform.xml b/mod_jdsimplecontactform.xml index 0901476..9d31b98 100644 --- a/mod_jdsimplecontactform.xml +++ b/mod_jdsimplecontactform.xml @@ -121,6 +121,12 @@ label="MOD_JDSCF_EMAIL_TO_LBL" description="MOD_JDSCF_EMAIL_TO_DESC" /> + Date: Wed, 6 Mar 2019 12:02:06 +0530 Subject: [PATCH 05/14] Improved Error Messages when Ajax Enabled. Replaced "Something went wrong! Please try again." with backend errors. --- helper.php | 17 ++++++++++++----- tmpl/default.php | 10 +++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/helper.php b/helper.php index 8dab2b9..e485774 100644 --- a/helper.php +++ b/helper.php @@ -246,6 +246,7 @@ public static function submitForm($ajax = false) { } if(!empty($errors)) { $app = JFactory::getApplication(); + $send = false; //showing all the validation errors foreach ($errors as $error) { $app->enqueueMessage(\JText::_($error), 'error'); @@ -256,7 +257,13 @@ public static function submitForm($ajax = false) { } if ($send !== true) { - throw new \Exception(JText::_('MOD_JDSCFEMAIL_SEND_ERROR')); + switch($params->get('ajaxsubmit')) + { + case 0: throw new \Exception(JText::_('MOD_JDSCFEMAIL_SEND_ERROR')); + break; + case 1: throw new \Exception(json_encode($errors)); + break; + } } $message = $params->get('thankyou_message', ''); if (empty($message)) { @@ -277,7 +284,7 @@ public static function submitForm($ajax = false) { } $app->redirect($return); } - return ['message' => $message, 'redirect' => $redirect_url]; + return ['message' => $message, 'redirect' => $redirect_url, 'errors' => json_encode($errors)]; } public static function renderVariables($variables, $source) { @@ -398,17 +405,17 @@ public static function uploadFile($name, $src) { else { $tmppath = JPATH_SITE . '/tmp'; - if(!file_exists($tmppath.'/jdscf')){ + if (!file_exists($tmppath.'/jdscf')) { mkdir($tmppath.'/jdscf',0777); } $folder = md5(time().'-'.$filename.rand(0,99999)); - if(!file_exists($tmppath.'/jdscf/'.$folder)){ + if (!file_exists($tmppath.'/jdscf/'.$folder)) { mkdir($tmppath.'/jdscf/'.$folder,0777); } $dest = $tmppath.'/jdscf/'.$folder.'/'.$filename; $return = null; - if (JFile::upload($src, $dest)){ + if (JFile::upload($src, $dest)) { $return = $dest; } return $return; diff --git a/tmpl/default.php b/tmpl/default.php index f787b1a..9250d6c 100644 --- a/tmpl/default.php +++ b/tmpl/default.php @@ -134,7 +134,6 @@ contentType: false, processData: false, success: function (response) { - if (response.status == 'success') { $('.jd-simple-contact-message-id; ?>').html(response.data.message); _loading.addClass('d-none'); @@ -144,8 +143,13 @@ }, 2000); } } else { - _loading.addClass('d-none'); - showMessageid; ?>("error", ""); + var errors = JSON.parse(response.message); + _loading.addClass('d-none'); + + for (index = 0; index < errors.length; ++index) { + showMessageid; ?>("error", errors[index]); + } + } }, error: function (response) { From b72cd54a13e156eec285a3a60393a13e970d9f96 Mon Sep 17 00:00:00 2001 From: actuallyakash Date: Fri, 8 Mar 2019 11:28:27 +0530 Subject: [PATCH 06/14] Added custom fields/Overrides for Reply-to field --- helper.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/helper.php b/helper.php index e485774..027388e 100644 --- a/helper.php +++ b/helper.php @@ -215,10 +215,15 @@ public static function submitForm($ajax = false) { } // Reply-To - $reply_to = !empty($params->get('reply_to', '')) ? $params->get('reply_to') : ''; - $reply_to = explode(',', $reply_to); - if (!empty($reply_to)) { + if (!empty($params->get('reply_to', ''))) { + $reply_to = $params->get('reply_to', ''); + $reply_to = self::renderVariables($contents, $reply_to); + if (!filter_var($reply_to, FILTER_VALIDATE_EMAIL)) { + $reply_to = ''; + } $mailer->addReplyTo($reply_to); + } else { + $reply_to = ''; } // CC From 745e819a137b7295c790904d97c1bc50317f6025 Mon Sep 17 00:00:00 2001 From: actuallyakash Date: Fri, 8 Mar 2019 11:54:11 +0530 Subject: [PATCH 07/14] Minor Language Fix --- language/en-GB/en-GB.mod_jdsimplecontactform.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/en-GB/en-GB.mod_jdsimplecontactform.ini b/language/en-GB/en-GB.mod_jdsimplecontactform.ini index 9ad085b..3fb0bfa 100644 --- a/language/en-GB/en-GB.mod_jdsimplecontactform.ini +++ b/language/en-GB/en-GB.mod_jdsimplecontactform.ini @@ -115,7 +115,7 @@ MOD_JDSCF_EMAIL_TO_LBL="Email Address" MOD_JDSCF_EMAIL_TO_DESC="Enter the email address to recieve submissions. Use comma to seperate multiple emails." MOD_JDSCF_REPLY_TO_LBL="Reply-to Email" -MOD_JDSCF_REPLY_TO_DESC="Enter the email Reply-to email address" +MOD_JDSCF_REPLY_TO_DESC="Enter the Reply-to email address" MOD_JDSCF_EMAIL_CC_LBL="CC Email" MOD_JDSCF_EMAIL_CC_DESC="CC email address to recieve submissions. Use comma to seperate multiple emails." From f69b17d5a9980e0061c42a60279f6f0371265827 Mon Sep 17 00:00:00 2001 From: actuallyakash Date: Tue, 12 Mar 2019 12:16:34 +0530 Subject: [PATCH 08/14] Updated Submit Button to Dynamic Field Now user can set the width of the submit button. --- .../en-GB/en-GB.mod_jdsimplecontactform.ini | 3 + layouts/fields/submit.php | 5 +- mod_jdsimplecontactform.xml | 17 +++++ tmpl/default.php | 69 +++++++++---------- 4 files changed, 55 insertions(+), 39 deletions(-) diff --git a/language/en-GB/en-GB.mod_jdsimplecontactform.ini b/language/en-GB/en-GB.mod_jdsimplecontactform.ini index 3fb0bfa..8247fa3 100644 --- a/language/en-GB/en-GB.mod_jdsimplecontactform.ini +++ b/language/en-GB/en-GB.mod_jdsimplecontactform.ini @@ -61,6 +61,9 @@ MOD_JDSCF_TYPE_DESC="Select the type of the field." MOD_JDSCF_WIDTH_LBL="Width" MOD_JDSCF_WIDTH_DESC="Select a width between 2 - 12, This is based on bootstrap grid system, More info at https://getbootstrap.com/docs/." +MOD_JDSCF_SUBMIT_WIDTH_LBL="Submit Button Width" +MOD_JDSCF_SUBMIT_WIDTH_DESC="Select a width between 2 - 12, This is based on bootstrap grid system, More info at https://getbootstrap.com/docs/." + MOD_JDSCF_PLACEHOLDER_LBL="Placeholder" MOD_JDSCF_PLACEHOLDER_DESC="Enter to add placeholder on this input." diff --git a/layouts/fields/submit.php b/layouts/fields/submit.php index 97722a9..97317ef 100644 --- a/layouts/fields/submit.php +++ b/layouts/fields/submit.php @@ -10,7 +10,8 @@ extract($displayData); $buttonText = $params->get('submittext', 'JSUBMIT'); $buttonClass = $params->get('submitclass', 'btn-primary'); +$buttonWidth = $params->get('submit_btn_width', '12'); ?> -
    - +
    +
    \ No newline at end of file diff --git a/mod_jdsimplecontactform.xml b/mod_jdsimplecontactform.xml index 9d31b98..bfbe358 100644 --- a/mod_jdsimplecontactform.xml +++ b/mod_jdsimplecontactform.xml @@ -95,6 +95,23 @@
    + + + + + + + + + + + +
    -
    - trigger('onInit', 'jdscf_recaptcha_' . $module->id); - $plugin = JPluginHelper::getPlugin('captcha', 'recaptcha'); - if (!empty($plugin)) { - $plugin_params = new JRegistry($plugin->params); - $attributes = []; - $attributes['data-theme'] = $plugin_params->get('theme2', ''); - $attributes['data-size'] = $plugin_params->get('size', ''); - $attributeArray = []; - foreach ($attributes as $attributeKey => $attributeValue) { - $attributeArray[] = $attributeKey . '="' . $attributeValue . '"'; - } - ?> -
    -
    -
    -
    >
    + if ($captcha) { + JPluginHelper::importPlugin('captcha'); + $dispatcher = JEventDispatcher::getInstance(); + $dispatcher->trigger('onInit', 'jdscf_recaptcha_' . $module->id); + $plugin = JPluginHelper::getPlugin('captcha', 'recaptcha'); + if (!empty($plugin)) { + $plugin_params = new JRegistry($plugin->params); + $attributes = []; + $attributes['data-theme'] = $plugin_params->get('theme2', ''); + $attributes['data-size'] = $plugin_params->get('size', ''); + $attributeArray = []; + foreach ($attributes as $attributeKey => $attributeValue) { + $attributeArray[] = $attributeKey . '="' . $attributeValue . '"'; + } + ?> +
    +
    +
    +
    >
    +
    +
    -
    -
    - + -
    -
    -
    +
    render(['params' => $params]); - } ?> -
    + $singleCC = new JLayoutFile('fields.singlecc', JPATH_SITE . '/modules/mod_jdsimplecontactform/layouts'); + echo $singleCC->render(['params' => $params]); + } + ?>
    -
    -
    render(['params' => $params]); ?> +
    + From 07c87ce606986f7677d54146fc04b0bb3b890935 Mon Sep 17 00:00:00 2001 From: actuallyakash Date: Thu, 14 Mar 2019 17:15:55 +0530 Subject: [PATCH 09/14] Added custom error message field Custom error message field for required input controls. --- forms/fielditem.xml | 7 ++++ .../en-GB/en-GB.mod_jdsimplecontactform.ini | 3 ++ layouts/fields/calendar.php | 32 +++++++++++-------- layouts/fields/checkbox.php | 9 +++++- layouts/fields/checkboxes.php | 6 +++- layouts/fields/file.php | 8 +++-- layouts/fields/list.php | 6 +++- layouts/fields/radio.php | 6 +++- layouts/fields/text.php | 6 +++- layouts/fields/textarea.php | 10 ++++-- 10 files changed, 69 insertions(+), 24 deletions(-) diff --git a/forms/fielditem.xml b/forms/fielditem.xml index 23140d2..44a3eb9 100644 --- a/forms/fielditem.xml +++ b/forms/fielditem.xml @@ -47,6 +47,13 @@ + placeholder) && !empty($field->placeholder)) { - $attrs[] = 'placeholder="' . $field->placeholder . '"'; + $attrs[] = 'placeholder="' . $field->placeholder . '"'; } if (!empty($field->id)) { - $attrs[] = 'id="' . $field->id . '"'; + $attrs[] = 'id="' . $field->id . '"'; } if ($field->required) { - $attrs[] = 'required'; - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + $attrs[] = 'required'; + if (!empty(trim($field->custom_error))) { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + } else { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + } } $document = JFactory::getDocument(); $style = 'label.calendar_icon {' - . 'display: inherit;' - . 'cursor: pointer;' - . 'margin: 0px;' - . 'border-radius: 0;' - . '}'; + . 'display: inherit;' + . 'cursor: pointer;' + . 'margin: 0px;' + . 'border-radius: 0;' + . '}'; $document->addStyleDeclaration($style); ?> @@ -45,17 +49,17 @@ id . ' = new Pikaday({' - . 'field: document.getElementById("' . $field->id . '")'; +. 'field: document.getElementById("' . $field->id . '")'; if (isset($field->calendar_min) && !empty($field->calendar_min) && $field->calendar_min != '0000-00-00 00:00:00') { - $js .= ',minDate: moment("' . $field->calendar_min . '").toDate()'; + $js .= ',minDate: moment("' . $field->calendar_min . '").toDate()'; } if (isset($field->calendar_max) && !empty($field->calendar_max) && $field->calendar_max != '0000-00-00 00:00:00') { - $js .= ',maxDate: moment("' . $field->calendar_max . '").toDate()'; + $js .= ',maxDate: moment("' . $field->calendar_max . '").toDate()'; } if (isset($field->calendar_format) && !empty($field->calendar_format)) { - $js .= ',format: "' . $field->calendar_format . '"'; + $js .= ',format: "' . $field->calendar_format . '"'; } else { - $js .= ',format: "MM-DD-YYYY"'; + $js .= ',format: "MM-DD-YYYY"'; } $js .= ',defaultDate: moment("' . date('Y-m-d') . '").toDate(),setDefaultDate:true'; diff --git a/layouts/fields/checkbox.php b/layouts/fields/checkbox.php index 50342cb..48287d3 100644 --- a/layouts/fields/checkbox.php +++ b/layouts/fields/checkbox.php @@ -9,10 +9,17 @@ defined('_JEXEC') or die; extract($displayData); $options = ModJDSimpleContactFormHelper::getOptions($field->options); + +// die(print_r(empty(trim($field->custom_error)))); + $attrs = []; if ($field->required) { $attrs[] = 'required'; - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + if (!empty(trim($field->custom_error))) { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + } else { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + } } ?>
    diff --git a/layouts/fields/checkboxes.php b/layouts/fields/checkboxes.php index c21ea25..57fb556 100644 --- a/layouts/fields/checkboxes.php +++ b/layouts/fields/checkboxes.php @@ -12,7 +12,11 @@ $attrs = []; if ($field->required) { $attrs[] = 'required'; - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + if (!empty(trim($field->custom_error))) { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + } else { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + } } $optionslayout = isset($field->optionslayout) ? $field->optionslayout : 'vertical'; ?> diff --git a/layouts/fields/file.php b/layouts/fields/file.php index a8dbb16..89c7fc6 100644 --- a/layouts/fields/file.php +++ b/layouts/fields/file.php @@ -10,8 +10,12 @@ extract($displayData); $attrs = []; if ($field->required) { - $attrs[] = 'required'; - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + $attrs[] = 'required'; + if (!empty(trim($field->custom_error))) { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + } else { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + } } $attrs[] = 'id="' . $field->name . '-file-input"'; //fetching allowed types diff --git a/layouts/fields/list.php b/layouts/fields/list.php index 4ec1564..ac56fe3 100644 --- a/layouts/fields/list.php +++ b/layouts/fields/list.php @@ -12,7 +12,11 @@ $attrs = []; if ($field->required) { $attrs[] = 'required'; - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + if (!empty(trim($field->custom_error))) { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + } else { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + } } ?> /> diff --git a/layouts/fields/textarea.php b/layouts/fields/textarea.php index 62cf37e..f6887c0 100644 --- a/layouts/fields/textarea.php +++ b/layouts/fields/textarea.php @@ -10,9 +10,13 @@ extract($displayData); $attrs = []; if ($field->required) { - $attrs[] = 'required'; - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; -} + $attrs[] = 'required'; + if (!empty(trim($field->custom_error))) { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + } else { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + } + } if (isset($field->placeholder) && !empty($field->placeholder)) { $attrs[] = 'placeholder="' . $field->placeholder . '"'; } From 0e9c5e2a5f3d1477fd8296746f67cb999efcc2eb Mon Sep 17 00:00:00 2001 From: actuallyakash Date: Thu, 14 Mar 2019 17:18:40 +0530 Subject: [PATCH 10/14] Refactored --- layouts/fields/checkbox.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/layouts/fields/checkbox.php b/layouts/fields/checkbox.php index 48287d3..f5fc6d6 100644 --- a/layouts/fields/checkbox.php +++ b/layouts/fields/checkbox.php @@ -9,9 +9,6 @@ defined('_JEXEC') or die; extract($displayData); $options = ModJDSimpleContactFormHelper::getOptions($field->options); - -// die(print_r(empty(trim($field->custom_error)))); - $attrs = []; if ($field->required) { $attrs[] = 'required'; From 8d7b1ddaae4c963962a735d86b187be251104723 Mon Sep 17 00:00:00 2001 From: actuallyakash Date: Fri, 15 Mar 2019 09:37:51 +0530 Subject: [PATCH 11/14] Language Updated --- forms/fielditem.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms/fielditem.xml b/forms/fielditem.xml index 44a3eb9..4cb093a 100644 --- a/forms/fielditem.xml +++ b/forms/fielditem.xml @@ -52,7 +52,7 @@ name="custom_error" type="text" label="MOD_JDSCF_CUSTOM_ERROR_LBL" - description="Show a custom error message when fields are required." + description="MOD_JDSCF_CUSTOM_ERROR_DESC" /> Date: Mon, 18 Mar 2019 11:08:31 +0530 Subject: [PATCH 12/14] Fixed Minor Issues and formatting --- .../en-GB/en-GB.mod_jdsimplecontactform.ini | 4 +-- layouts/fields/singlecc.php | 5 ++- layouts/fields/submit.php | 2 +- mod_jdsimplecontactform.xml | 32 +++++++++---------- tmpl/default.php | 16 ++++------ 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/language/en-GB/en-GB.mod_jdsimplecontactform.ini b/language/en-GB/en-GB.mod_jdsimplecontactform.ini index adcb475..d4543ef 100644 --- a/language/en-GB/en-GB.mod_jdsimplecontactform.ini +++ b/language/en-GB/en-GB.mod_jdsimplecontactform.ini @@ -48,7 +48,7 @@ MOD_JDSCF_SHOW_LABEL_DESC="Select to display the label before the field." MOD_JDSCF_OPTIONS_LAYOUT_LBL="Options Layout" MOD_JDSCF_OPTIONS_LAYOUT_DESC="Select to display checkboxes and radios in vertically or stacked layout." -MOD_JDSCF_FORM_SUBMIT_LBL="Submit button text" +MOD_JDSCF_FORM_SUBMIT_LBL="Submit Button Text" MOD_JDSCF_FORM_SUBMIT_DESC="Enter to change text for the submit button. Default is Submit." MOD_JDSCF_FORM_SUBMIT_DEFAULT="Submit" @@ -158,7 +158,7 @@ MOD_JDSCF_THANKYOU_MESSAGE_DESC="Enter a Thank you message to be displayed after MOD_JDSCF_REDIRECT_LBL="Redirect URL" MOD_JDSCF_REDIRECT_DESC="Enter a URL to redirect users after submission. Leave blank to if not required. (You can use {field:label} & {field:value} to render dynamic values in this field)" -MOD_JDSCF_SUBMITBTN_CLASS_LBL="Submit button class" +MOD_JDSCF_SUBMITBTN_CLASS_LBL="Submit Button Class" MOD_JDSCF_SUBMITBTN_CLASS_DESC="" MOD_JDSCF_UNSUPPORTED_FILE_ERROR="Unsupported Filetype" diff --git a/layouts/fields/singlecc.php b/layouts/fields/singlecc.php index df0b9e7..780b184 100644 --- a/layouts/fields/singlecc.php +++ b/layouts/fields/singlecc.php @@ -11,4 +11,7 @@ $singleCCName = $params->get('singleSendCopyEmail_field', ''); $singleCCTitle = $params->get('singleSendCopyEmailField_title', 'MOD_JDSCF_SINGLE_SEND_COPY_LBL_TITLE'); ?> - \ No newline at end of file +
    +
    + \ No newline at end of file diff --git a/layouts/fields/submit.php b/layouts/fields/submit.php index 97317ef..dffbd33 100644 --- a/layouts/fields/submit.php +++ b/layouts/fields/submit.php @@ -13,5 +13,5 @@ $buttonWidth = $params->get('submit_btn_width', '12'); ?>
    - +
    \ No newline at end of file diff --git a/mod_jdsimplecontactform.xml b/mod_jdsimplecontactform.xml index bfbe358..500e1cb 100644 --- a/mod_jdsimplecontactform.xml +++ b/mod_jdsimplecontactform.xml @@ -79,22 +79,6 @@ description="MOD_JDSCF_SUBMITBTN_CLASS_DESC" default="btn-primary" /> - - - -
    - 3 + + +
    +
    +
    - -
    - render(['params' => $params]); - } - ?> -
    + + render(['params' => $params]); + } + ?> Date: Mon, 25 Mar 2019 11:56:09 +0530 Subject: [PATCH 13/14] Modified Upload Field It'll show filenames in upload field when uploaded. --- .../en-GB/en-GB.mod_jdsimplecontactform.ini | 4 ++-- layouts/fields/checkbox.php | 13 +++++++------ layouts/fields/checkboxes.php | 4 ++-- layouts/fields/file.php | 19 +++++++++++++++---- layouts/fields/list.php | 10 ++++++---- layouts/fields/radio.php | 4 ++-- layouts/fields/text.php | 4 ++-- layouts/fields/textarea.php | 4 ++-- tmpl/default.php | 8 +++----- 9 files changed, 41 insertions(+), 29 deletions(-) diff --git a/language/en-GB/en-GB.mod_jdsimplecontactform.ini b/language/en-GB/en-GB.mod_jdsimplecontactform.ini index d4543ef..80c585a 100644 --- a/language/en-GB/en-GB.mod_jdsimplecontactform.ini +++ b/language/en-GB/en-GB.mod_jdsimplecontactform.ini @@ -83,10 +83,10 @@ MOD_JDSCF_TYPE_CALENDAR_LBL="Calendar" MOD_JDSCF_TYPE_LIST_LBL="List" MOD_JDSCF_OPTIONS_LBL="Options" -MOD_JDSCF_OPTIONS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum." +MOD_JDSCF_OPTIONS_DESC="Enter return seperated values." MOD_JDSCF_CSS_LBL="Load CSS" -MOD_JDSCF_CSS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum." +MOD_JDSCF_CSS_DESC="" MOD_JDSCF_REQUIRED_ERROR="%s is required." diff --git a/layouts/fields/checkbox.php b/layouts/fields/checkbox.php index f5fc6d6..359a68d 100644 --- a/layouts/fields/checkbox.php +++ b/layouts/fields/checkbox.php @@ -10,13 +10,14 @@ extract($displayData); $options = ModJDSimpleContactFormHelper::getOptions($field->options); $attrs = []; + if ($field->required) { - $attrs[] = 'required'; - if (!empty(trim($field->custom_error))) { - $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; - } else { - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; - } + $attrs[] = 'required'; + if (!empty(trim($field->custom_error))) { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + } else { + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + } } ?>
    diff --git a/layouts/fields/checkboxes.php b/layouts/fields/checkboxes.php index 57fb556..a561235 100644 --- a/layouts/fields/checkboxes.php +++ b/layouts/fields/checkboxes.php @@ -13,9 +13,9 @@ if ($field->required) { $attrs[] = 'required'; if (!empty(trim($field->custom_error))) { - $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; } else { - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; } } $optionslayout = isset($field->optionslayout) ? $field->optionslayout : 'vertical'; diff --git a/layouts/fields/file.php b/layouts/fields/file.php index 89c7fc6..357b82b 100644 --- a/layouts/fields/file.php +++ b/layouts/fields/file.php @@ -12,11 +12,11 @@ if ($field->required) { $attrs[] = 'required'; if (!empty(trim($field->custom_error))) { - $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; + $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; } else { - $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; + $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; } -} + } $attrs[] = 'id="' . $field->name . '-file-input"'; //fetching allowed types $params = JComponentHelper::getParams('com_media'); @@ -31,7 +31,7 @@ ?>
    " type="file" name="jdscf[name; ?>]" class="custom-file-input" > - +
    @@ -55,5 +55,16 @@ $js .= '}'; $js .= '};'; + +// $js .= "jQuery('#" . $field->name . '-' .$module->id . "').on('change', function() {"; +// $js .= "var fileName = jQuery(this).val().split('\\').pop();"; +// $js .= "jQuery(this).siblings('.custom-file-label').addClass('selected').html(fileName);"; +// $js .= "});"; + +$js .= 'jQuery("#' . $field->name . '-' .$module->id . '").on("change", function() {'; + $js .= 'var fileName = jQuery(this).val().split("\\\").pop();'; + $js .= 'jQuery(this).siblings(".custom-file-label").addClass("selected").html(fileName);'; +$js .= '});'; + ModJDSimpleContactFormHelper::addJS($js, $module->id); ?> \ No newline at end of file diff --git a/layouts/fields/list.php b/layouts/fields/list.php index ac56fe3..7f44b5c 100644 --- a/layouts/fields/list.php +++ b/layouts/fields/list.php @@ -10,13 +10,15 @@ extract($displayData); $options = ModJDSimpleContactFormHelper::getOptions($field->options); $attrs = []; + + if ($field->required) { - $attrs[] = 'required'; - if (!empty(trim($field->custom_error))) { + $attrs[] = 'required'; + if (!empty(trim($field->custom_error))) { $attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"'; - } else { + } else { $attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"'; - } + } } ?>