• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: CGBetterforms add dynamic fields - no submit
PostPosted: Thu May 07, 2020 10:03 am 
Offline
Forum Members
Forum Members

Joined: Fri Jun 26, 2009 3:04 pm
Posts: 14
Hello

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
\$1:
<__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>


and then this in my form template
\$1:
 <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>


The form itself on the website works fine. I can add and remove, wenn I look into the form information ( firefox webtool), the fields are there.
I have updated the handler and it shows
\$1:
{if !empty($title)}<p><strong>title:</strong> {implode(' + ',$title)}{$title}</p>{/if}

Also in the form templating help it's listed with
\$1:
title    string[]


But when I submit, it doesn't show up in my email, nor in the flat cvs file.
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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterforms add dynamic fields - no submit
PostPosted: Thu May 07, 2020 1:58 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Feb 25, 2009 4:25 am
Posts: 968
Location: Victoria, BC
CGBF isn't really built to handle dynamically-added fields. When you create the form template and scan it into the module, that's when it builds the list of fields etc that it handles. It can't know that they will be added later with js.

You can add options to a dropdown (for example) dynamically, but the actual input field with its name must be there during the form scan. At best, you could hide the fields then just set them to show dynamically, but you couldn't do an indefinite "add field" scenario.

_________________
Not getting the answer you need? CMSMS support options


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterforms add dynamic fields - no submit [solved]
PostPosted: Thu May 07, 2020 2:05 pm 
Offline
Forum Members
Forum Members

Joined: Fri Jun 26, 2009 3:04 pm
Posts: 14
thank you for your quick answer. No problem, then I will change the form a little bt. But now I know at least that's not possible and can stop trying :-)

Have a nice day


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterforms add dynamic fields - no submit
PostPosted: Thu May 07, 2020 2:09 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Mon Jan 29, 2007 4:47 pm
Posts: 1786
Just for the record: that could have been easily done with FormBuilder.

_________________
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).


Code of Conduit | CMSMS Docs
Help Support CMSMS
My developer Page on the Forge | Yet another blog about CMSMS

GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting