We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20180
    • 29 Posts
    Hello

    My discovery after losing 3hours+ on a strange bug in formit. I had 2 forms on one page for a hotel. One simple contact form, and another "booking" form.

    Both forms had an email field. So to help formit work properly I have changed all the name fields in the second form (as someone suggested) so for example. "firstname" field in first form vs "firstnameb" in another.

    And this is strange: when I have changed email name in the other form to emailb - formit started to behave anormally. It was sending the form but redirect and autoresponder didnt work no more. I first thought I have some subtle error on the form that throws formit offbalance, maybe some divs intertwined with inputs.

    Checked everything! Yet it didnt work. Then I duplicated one working form to a fresh document and then I found this.

    the email field for formit has to have name="email" ALWAYS. if you do smth like this input name="address" id="address" type="email" IT WONT WORK!

    At least I didn't find a workaround.


    Best regards [ed. note: BobRay last edited this post 11 years, 3 months ago.]
      Kind Regards
      ====================
      montagproject
      • 20180
      • 29 Posts
      NOT WORKING EXAMPLE:

      <!-- Text input-->
      <div class="form-group col-md-4">
        <label class="control-label" for="emailb">Adres email <span class="label label-important">[[!+fi.error.emailb]]</span></label>
        <input id="emailb" name="emailb" type="emailb" placeholder="" class="form-control" required="" value="[[!fi.emailb]]">
        <p class="help-block">Proszę wpisać poprawny adres, abyśmy mogli się z Państwem skontaktować</p>
      </div>



      ==============================================

      WORKING EXAMPLE:

      <!-- Text input-->
      <div class="form-group col-md-4">
       <label class="control-label" for="email">Adres email <span class="label label-important">[[!+fi.error.email]]</span></label>
      <input id="emailb" name="email" type="email" placeholder="" class="form-control" required="" value="[[!fi.email]]">
      <p class="help-block">Proszę wpisać poprawny adres, abyśmy mogli się z Państwem skontaktować</p>
      </div>
        Kind Regards
        ====================
        montagproject
        • 3749
        • 24,544 Posts
        I think this is the code in the FormIt email hook that's causing that:

        $emailFrom = !empty($fields['email']) ? $fields['email'] : $this->modx->getOption('emailsender');


        It shouldn't be too difficult to make the field name a property for the FormIt snippet tag. I think this would work:

        &emailFromField=`emailb`


        Replace the line at the top with these two lines:

        $emailFromField = $modx->getOption('emailFromField', $this->formit->config, 'email', true);
        $emailFrom = !empty($fields[$emailFromField]) ? $fields[$emailFromField] : $this->modx->getOption('emailsender');
        



          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting