Skip to content

Commit f69b17d

Browse files
committed
Updated Submit Button to Dynamic Field
Now user can set the width of the submit button.
1 parent 745e819 commit f69b17d

File tree

4 files changed

+55
-39
lines changed

4 files changed

+55
-39
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ MOD_JDSCF_TYPE_DESC="Select the type of the field."
6161
MOD_JDSCF_WIDTH_LBL="Width"
6262
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>."
6363

64+
MOD_JDSCF_SUBMIT_WIDTH_LBL="Submit Button Width"
65+
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>."
66+
6467
MOD_JDSCF_PLACEHOLDER_LBL="Placeholder"
6568
MOD_JDSCF_PLACEHOLDER_DESC="Enter to add placeholder on this input."
6669

layouts/fields/submit.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
extract($displayData);
1111
$buttonText = $params->get('submittext', 'JSUBMIT');
1212
$buttonClass = $params->get('submitclass', 'btn-primary');
13+
$buttonWidth = $params->get('submit_btn_width', '12');
1314
?>
14-
<div class="jdscf-col">
15-
<button type="submit" class="btn<?php echo!empty($buttonClass) ? ' ' . $buttonClass : ''; ?>"><?php echo JText::_($buttonText); ?></button>
15+
<div class="jdscf-col-md-<?php echo $buttonWidth ?>">
16+
<button type="submit" class="form-control btn<?php echo!empty($buttonClass) ? ' ' . $buttonClass : ''; ?> btn-block"><?php echo JText::_($buttonText); ?></button>
1617
</div>

mod_jdsimplecontactform.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@
9595
</fieldset>
9696
<fieldset name="fields" label="MOD_JDSCF_FORM_FIELDS_OPTIONS_LBL">
9797
<field name="fields" type="subform" formsource="modules/mod_jdsimplecontactform/forms/fielditem.xml" multiple="true" label="MOD_JDSCF_FIELDS_LBL" />
98+
<field
99+
name="submit_btn_width"
100+
type="list"
101+
label="MOD_JDSCF_SUBMIT_WIDTH_LBL"
102+
description="MOD_JDSCF_SUBMIT_WIDTH_DESC"
103+
>
104+
<option value="12">12</option>
105+
<option value="10">10</option>
106+
<option value="9">9</option>
107+
<option value="8">8</option>
108+
<option value="7">7</option>
109+
<option value="6">6</option>
110+
<option value="5">5</option>
111+
<option value="4">4</option>
112+
<option value="3">3</option>
113+
<option value="2">2</option>
114+
</field>
98115
</fieldset>
99116
<fieldset name="email" label="MOD_JDSCF_EMAIL_OPTIONS_LBL">
100117
<field

tmpl/default.php

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,55 +38,50 @@
3838
<div class="jdscf-row">
3939
<?php
4040
ModJDSimpleContactFormHelper::renderForm($params, $module);
41-
?>
42-
</div>
4341

44-
<?php
45-
if ($captcha) {
46-
JPluginHelper::importPlugin('captcha');
47-
$dispatcher = JEventDispatcher::getInstance();
48-
$dispatcher->trigger('onInit', 'jdscf_recaptcha_' . $module->id);
49-
$plugin = JPluginHelper::getPlugin('captcha', 'recaptcha');
50-
if (!empty($plugin)) {
51-
$plugin_params = new JRegistry($plugin->params);
52-
$attributes = [];
53-
$attributes['data-theme'] = $plugin_params->get('theme2', '');
54-
$attributes['data-size'] = $plugin_params->get('size', '');
55-
$attributeArray = [];
56-
foreach ($attributes as $attributeKey => $attributeValue) {
57-
$attributeArray[] = $attributeKey . '="' . $attributeValue . '"';
58-
}
59-
?>
60-
<div class="jdscf-row">
61-
<div class="jdscf-col">
62-
<div class="form-group">
63-
<div id="jdscf_recaptcha_<?php echo $module->id; ?>" class="g-recaptcha" data-sitekey="<?php echo $plugin_params->get('public_key', ''); ?>" <?php echo implode(' ', $attributeArray); ?>></div>
42+
if ($captcha) {
43+
JPluginHelper::importPlugin('captcha');
44+
$dispatcher = JEventDispatcher::getInstance();
45+
$dispatcher->trigger('onInit', 'jdscf_recaptcha_' . $module->id);
46+
$plugin = JPluginHelper::getPlugin('captcha', 'recaptcha');
47+
if (!empty($plugin)) {
48+
$plugin_params = new JRegistry($plugin->params);
49+
$attributes = [];
50+
$attributes['data-theme'] = $plugin_params->get('theme2', '');
51+
$attributes['data-size'] = $plugin_params->get('size', '');
52+
$attributeArray = [];
53+
foreach ($attributes as $attributeKey => $attributeValue) {
54+
$attributeArray[] = $attributeKey . '="' . $attributeValue . '"';
55+
}
56+
?>
57+
<div class="jdscf-row">
58+
<div class="jdscf-col">
59+
<div class="form-group">
60+
<div id="jdscf_recaptcha_<?php echo $module->id; ?>" class="g-recaptcha" data-sitekey="<?php echo $plugin_params->get('public_key', ''); ?>" <?php echo implode(' ', $attributeArray); ?>></div>
61+
</div>
62+
</div>
6463
</div>
65-
</div>
66-
</div>
67-
<?php
68-
}
69-
}
70-
?>
64+
<?php
65+
}
66+
}
67+
?>
7168

72-
<div class="jdscf-row">
73-
<div class="jdscf-col">
74-
<div class="form-group">
69+
<div class="form-group">
7570
<?php
7671
if($single_cc_enable) {
77-
$singleCC = new JLayoutFile('fields.singlecc', JPATH_SITE . '/modules/mod_jdsimplecontactform/layouts');
78-
echo $singleCC->render(['params' => $params]);
79-
} ?>
80-
</div>
72+
$singleCC = new JLayoutFile('fields.singlecc', JPATH_SITE . '/modules/mod_jdsimplecontactform/layouts');
73+
echo $singleCC->render(['params' => $params]);
74+
}
75+
?>
8176
</div>
82-
</div>
8377

84-
<div class="jdscf-row">
8578
<?php
8679
$submit = new JLayoutFile('fields.submit', JPATH_SITE . '/modules/mod_jdsimplecontactform/layouts');
8780
echo $submit->render(['params' => $params]);
8881
?>
82+
8983
</div>
84+
9085
<input type="hidden" name="returnurl" value="<?php echo urlencode(JUri::getInstance()); ?>"/>
9186
<input type="hidden" name="id" value="<?php echo $module->id; ?>" />
9287
<?php echo JHtml::_('form.token'); ?>

0 commit comments

Comments
 (0)