Support » Plugin: Dynamics 365 Integration » twig custom form – double verification

  • Resolved thepiweb

    (@thepiweb)


    Hi,

    I am using 2 custom twig forms on a page. In both forms I am using
    {% if form.submission and form.status %}
    to display success or error messages.
    The issue is that when I am submitting one form I have verification from both forms appearing.

    Here is screenshot

    Is there a way to avoid this form confusion?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author alexacrm

    (@alexacrm)

    Hi @thepiweb

    can you provide the twig snippets for both forms and the code displaying the message(s)?

    Thanks
    George

    Thread Starter thepiweb

    (@thepiweb)

    Hi George,

    The first form is placed on page content like this:

    {% form entity="mds_registrationcontact" mode="create"  %}
        {% if form.submission and form.status %}
        <div class="row">
        <div class="col-12">
        <div class="alert alert-success">{{ form.parameters.messages.success ?? "Ευχαριστούμε για την εγγραφή σας" }}</div>
        </div>
        </div>
        {% elseif form.submission and (not form.status) %}
        <div class="row">
        <div class="col-12">
        <div class="alert alert-danger">{% if form.parameters.messages.error %}
        {{ form.parameters.messages.error }}
        {% else %}
        {% for descriptor, message in form.errors %}
        <div>{{ descriptor }}: {{ message|join(', ') }}</div>
        {% endfor %}
        {% endif %}
            
        </div>
        </div>
        </div>
        {% endif %}        
        
        <form  method="POST" data-toggle="validator">
            <fieldset>
            <div class="form-group">
                {% set loc= eventlocations.results.entities[0].mds_location %}
                <input class="form-control" type="text" name="mds_eventlocationtext" value="{{loc}}" readonly />
            </div>
            <div class="form-group">
                <div class="select-wrap" id="mds_eventtitle">
                    <select name="mds_eventtitletext">
                        <option value="">-- Seminar Title --</option>
                        {% for eventtitle in eventtitles.results.entities %}
                        <option value="{{eventtitle.mds_title}}">{{eventtitle.mds_title}}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <div class="select-wrap" id="mds_event">
                    <select name="mds_eventfulltitletext">
                        <option value="">-- Event --</option>
                        {% for eventfulltitle in eventfulltitles.results.entities if eventfulltitle.mds_location == loc %}
                            <option value="{{eventfulltitle.mds_eventtitle}}" data-sem="{{eventfulltitle.mds_eventtitlelookup}}">{{eventfulltitle.mds_eventdate}}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>               
            <div class="form-group">
                <input class="form-control" name="mds_lastname" pattern="^[A-Za-zα-ωΑ-ΩΆΈΌΉΊϊΪϋΫέόώάίήύ\\s]*$" required="" type="text" placeholder="Όνομα:" data-required-error="Το πεδίο είναι απαραίτητο" data-pattern-error="To πεδίο δέχεται μόνο χαρακτήρες και το κενό" />
                <div class="help-block with-errors"></div>
            </div>
            
            <button class="btn btn-default" type="submit">Εγγραφή</button>
            </fieldset>
        </form> {% endform %}

    and the second is placed on the footer with a widget text like this:

    <div class="footer-newsletter">[msdyncrm_twig]
    {% form entity="lead" mode="create" language=1032 %}
    {% if form.submission and form.status %}
    <div class="row">
    <div class="col-12">
    <div class="alert alert-success">{{ form.parameters.messages.success ?? "Ευχαριστούμε για την εγγραφή σας στο Newsletter" }}</div>
    </div>
    </div>
    {% elseif form.submission and (not form.status) %}
    <div class="row">
    <div class="col-12">
    <div class="alert alert-danger">{% if form.parameters.messages.error %}
    {{ form.parameters.messages.error }}
    {% else %}
    {% for descriptor, message in form.errors %}
    <div>{{ descriptor }}: {{ message|join(', ') }}</div>
    {% endfor %}
    {% endif %}
    
    </div>
    </div>
    </div>
    {% endif %}
    
    <form class="form-inline" method="POST" data-toggle="validator">
    <fieldset>
    <div class="form-group">
    
    <input class="form-control" name="firstname" pattern="^[A-Za-zα-ωΑ-ΩΆΈΌΉΊϊΪϋΫέόώάίήύ\\s]*$" required="" type="text" placeholder="Όνομα:" data-required-error="Το πεδίο είναι απαραίτητο" data-pattern-error="To πεδίο δέχεται μόνο χαρακτήρες και το κενό" />
    <div class="help-block with-errors"></div>
    </div>
    <div class="form-group">
    
    <input class="form-control" name="lastname" pattern="^[A-Za-zα-ωΑ-ΩΆΈΌΉΊϊΪϋΫέόώάίήύ]*$" required="" type="text" placeholder="Επίθετο:" data-required-error="Το πεδίο είναι απαραίτητο" data-pattern-error="To πεδίο δέχεται μόνο χαρακτήρες" />
    <div class="help-block with-errors"></div>
    </div>
    <div class="form-group">
    
    <input class="form-control" name="emailaddress1" required="" type="email" placeholder="Email:" data-required-error="Το πεδίο είναι απαραίτητο" data-error="Μη έγκυρο email" />
    <div class="help-block with-errors"></div>
    </div>
    <button class="btn btn-default" type="submit">Εγγραφή</button></fieldset>
    </form>{% endform %}
    [/msdyncrm_twig]
    
    </div>

    On the first one I’ve only included the form code and not the whole twig tag because of the existence of many fetchxml snippets.

    Thanks

    Plugin Contributor wizardist

    (@wizardist)

    Hi @thepiweb

    The forms were not really designed to support a scenario with 2+ forms on a page.

    However we can add a way for the system to distinguish submissions from different forms, either automatically or manually.

    Thanks

    Thread Starter thepiweb

    (@thepiweb)

    Hi @wizardist

    We have the newsletter registration on the footer so if we could distinguish the submissions that would be greatly appreciated.

    Is there something I can do with the code or should we wait for an update on the plugin?

    Thanks

    Plugin Contributor wizardist

    (@wizardist)

    Hi @thepiweb

    You can upgrade to 1.2.19 and have two or more forms on one page.

    See the updated docs on custom forms: https://docs.alexacrm.com/wpcrm/twig/#displaying-custom-forms

    Just don’t forget to add different “key” attributes to form tags.

    Thanks

    Thread Starter thepiweb

    (@thepiweb)

    Thanks @wizardist,

    This was very helpful and resolved the issue.
    Although I was a little confused with the documentation.
    {{form.id}} didn’t return anything and the forms weren’t being submitted.
    I used {{form.key}} instead and it worked fine.

    Thanks again

    Plugin Contributor wizardist

    (@wizardist)

    @thepiweb

    Absolutely! What a grave misprint. Thanks for catching this one early.

    Have a nice day

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘twig custom form – double verification’ is closed to new replies.