After years of using formbuilder, I changed now to CGBetterforms. CMSMS 2.2.14, CGBetterforms 1.10.4
Everything provided by the templates works fine.
Now I wanted to add dynamic input fields (add/remove a row ) to the form.
I used this little snippet, very basic and easy
Code: Select all
<__script__ type="text/javascript">
// add row
$("#addRow").click(function () {
var html = '';
html += '<div id="inputFormRow">';
html += '<div class="input-group mb-3">';
html += '<input type="text" name="title[]" class="form-control m-input" placeholder="Enter title" autocomplete="off">';
html += '<div class="input-group-append">';
html += '<button id="removeRow" type="button" class="btn btn-danger">Remove</button>';
html += '</div>';
html += '</div>';
$('#newRow').append(html);
});
// remove row
$(document).on('click', '#removeRow', function () {
$(this).closest('#inputFormRow').remove();
});
</__script>
Code: Select all
<div class="row">
<div class="col-lg-12">
<div id="inputFormRow">
<div class="input-group mb-3">
<input type="text" name="title[]" class="form-control m-input" placeholder="Enter title" autocomplete="off">
<div class="input-group-append">
<button id="removeRow" type="button" class="btn btn-danger">Remove</button>
</div>
</div>
</div>
<div id="newRow"></div>
<button id="addRow" type="button" class="btn btn-info">Add Row</button>
</div>
</div>
I have updated the handler and it shows
Code: Select all
{if !empty($title)}<p><strong>title:</strong> {implode(' + ',$title)}{$title}</p>{/if}
Code: Select all
title string[]
The multiple string from a dropdown is submitted just fine.
Did I forgot something, or does the form need something more, to submit the string to my email?
I would appreciate some help or ideas.
Kind regards
Rednose