We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40225
    • 4 Posts
    FormIt Call:
    [[!FormIt? 
        &hooks=`customhook,email,spam,redirect` 
        &emailTpl=`FormMail` 
        &emailSubject=`Anmeldung`
        &emailTo=`[email protected]` 
        &redirectTo=`20` 
        &validate=`
            Name:required,
            Vorname:required,
            Firma:required,
            Funktion:required,
            Strasse:required,
            Postfach:required,
            PLZ:required,
            Ort:required,
            Land:required,
            Telefon:required,
    `]]


    Snippet: customhook
    <?php
    $modx->cacheManager->refresh();
    $modx->log(modX::LOG_LEVEL_ERROR, 'TESTRUN');
    return true;



    But there is no output in the logfile.
    Also an var_dump($_REQUEST); won't printed out.
    Whats wrong?

    Kind regards.
      • 1778
      • 659 Posts
      hello
      the formit call and the hook seem ok, maybe a problem with the form itself... Can you post it ?
      Cheers
        • 40225
        • 4 Posts
        Here's the form.
        [[!FormIt? 
            &hooks=`customhook,email,spam,redirect` 
            &emailTpl=`AnmeldeFormMail` 
            &emailSubject=`Anmeldung` 
            &emailTo=`abc_def_ghi` 
            &redirectTo=`20`
            &validate=`
            Name:required,
            Vorname:required,       
            Firma:required,       
            Funktion:required,       
            Strasse:required,       
            Postfach:required,        
            PLZ:required,        
            Ort:required,        
            Land:required,        
            Telefon:required,
            Email:email:required,
        `]]
        [[!+fi.error_message:notempty=`<p><span class="error">[[!+fi.error_message]]</span></p>`]]
        <form method="post">
          <fieldset>
            <h5>[[%form.headline? &namespace=`site`]]</h5>
            <label>[[%form.label.anrede? &namespace=`site`]]</label><input type="radio" name="Anrede" value="Frau" [[!+fi.Anrede:FormItIsChecked=`Frau`]]/> [[%form.label.frau? &namespace=`site`]]   <input type="radio" name="Anrede" value="Herr" [[!+fi.Anrede:FormItIsChecked=`Herr`]]/> [[%form.label.herr? &namespace=`site`]][[!+fi.error.Anrede:notempty=`<span class="error">[[%form.error.anrede? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.vorname? &namespace=`site`]]*</label><input type="text" name="Vorname" value="[[!+fi.Vorname]]" />[[!+fi.error.Vorname:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.name? &namespace=`site`]]*</label><input type="text" name="Name" value="[[!+fi.Name]]" />[[!+fi.error.Name:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.firma? &namespace=`site`]]*</label><input type="text" name="Firma" value="[[!+fi.Firma]]" />[[!+fi.error.Firma:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.funktion? &namespace=`site`]]*</label><input type="text" name="Funktion" value="[[!+fi.Funktion]]" />[[!+fi.error.Funktion:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
          </fieldset>
          <fieldset>
            <h5>[[%form.headline2? &namespace=`site`]]</h5>
            <label>[[%form.label.strasse? &namespace=`site`]]*</label><input type="text" name="Strasse" value="[[!+fi.Strasse]]" />[[!+fi.error.Strasse:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.postfach? &namespace=`site`]]</label><input type="text" name="Postfach" value="[[!+fi.Postfach]]" />[[!+fi.error.Postfach:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.plz? &namespace=`site`]]</label><input class="plz" type="text" name="PLZ" value="[[!+fi.PLZ]]" />[[!+fi.error.PLZ:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.ort? &namespace=`site`]]</label><input class="ort" type="text" name="Ort" value="[[!+fi.Ort]]" />[[!+fi.error.Ort:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.land? &namespace=`site`]]</label>
            <select name="Land">
                <option></option>
                <option value="CH" [[!+fi.Land:FormItIsSelected=`CH`]]>Schweiz</option>
                <option value="DE" [[!+fi.Land:FormItIsSelected=`DE`]]>Deutschland</option>
                <option value="FR" [[!+fi.Land:FormItIsSelected=`FR`]]>Frankreich</option>
                <option value="IT" [[!+fi.Land:FormItIsSelected=`IT`]]>Italien</option>
                <option value="AT" [[!+fi.Land:FormItIsSelected=`AT`]]>Österreich</option>        
            </select>[[!+fi.error.Land:notempty=`<span class="error">[[%form.error.land? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.telefon? &namespace=`site`]]</label><input type="text" name="Telefon" value="[[!+fi.Telefon]]" />[[!+fi.error.Telefon:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
            <label>[[%form.label.email? &namespace=`site`]]</label><input type="text" name="Email" value="[[!+fi.Email]]" />[[!+fi.error.Email:notempty=`<span class="error">[[%form.error.email? &namespace=`site`]]</span>`]]
            <div class="clearfix"></div>
          </fieldset>
          <fieldset>
            <h5>[[%form.headline3? &namespace=`site`]]</h5>
            <label> </label><input type="radio" name="Begleitung" value="alleine" [[!+fi.Begleitung:FormItIsChecked=`alleine`]]/>  [[%form.label.allein? &namespace=`site`]]<br />
            <div class="clearfix"></div>
            <label> </label><input type="radio" name="Begleitung" value="begleitung" [[!+fi.Begleitung:FormItIsChecked=`begleitung`]]/>  [[%form.label.begleitung? &namespace=`site`]]<br />
            <div class="clearfix"></div>
          </fieldset>
          <div class="second_form">
            <fieldset>
                <h5>[[%form.headline4? &namespace=`site`]]</h5>
                <label>[[%form.label.anrede? &namespace=`site`]]</label><input type="radio" name="AnredeBegleitung" value="Frau" /> [[%form.label.frau? &namespace=`site`]]   <input type="radio" name="Anrede" value="Herr" /> [[%form.label.herr? &namespace=`site`]][[!+fi.error.name:notempty=`<span class="error"></span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.vorname? &namespace=`site`]]*</label><input type="text" name="VornameBegleitung" value="[[!+fi.VornameBegleitung]]" />[[!+fi.error.VornameBegleitung:notempty=`<span class="error"></span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.name? &namespace=`site`]]*</label><input type="text" name="NameBegleitung" value="[[!+fi.NameBegleitung]]" />[[!+fi.error.NameBegleitung:notempty=`<span class="error"></span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.firma? &namespace=`site`]]*</label><input type="text" name="FirmaBegleitung" value="[[!+fi.FirmaBegleitung]]" />[[!+fi.error.FirmaBegleitung:notempty=`<span class="error"></span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.funktion? &namespace=`site`]]*</label><input type="text" name="FunktionBegleitung" value="[[!+fi.FunktionBegleitung]]" />[[!+fi.error.FunktionBegleitung:notempty=`<span class="error"></span>`]]
                <div class="clearfix"></div>
            </fieldset>
            <fieldset>
                <h5>[[%form.headline5? &namespace=`site`]]</h5>
                <label>[[%form.label.strasse? &namespace=`site`]]*</label><input type="text" name="StrasseBegleitung" value="[[!+fi.StrasseBegleitung]]" />[[!+fi.error.StrasseBegleitung:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.postfach? &namespace=`site`]]</label><input type="text" name="PostfachBegleitung" value="[[!+fi.PostfachBegleitung]]" />[[!+fi.error.PostfachBegleitung:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.plz? &namespace=`site`]]</label><input class="plz" type="text" name="PLZBegleitung" value="[[!+fi.PLZBegleitung]]" />[[!+fi.error.PLZBegleitung:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.ort? &namespace=`site`]]</label><input class="ort" type="text" name="OrtBegleitung" value="[[!+fi.OrtBegleitung]]" />[[!+fi.error.OrtBegleitung:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.land? &namespace=`site`]]</label><select name="LandBegleitung"><option value="CH" [[!+fi.LandBegleitung:FormItIsSelected=`CH`]]>Schweiz</option></select>[[!+fi.error.LandBegleitung:notempty=`<span class="error">[[%form.error.land? &namespace=`site`]]</span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.telefon? &namespace=`site`]]</label><input type="text" name="TelefonBegleitung" value="[[!+fi.TelefonBegleitung]]" />[[!+fi.error.TelefonBegleitung:notempty=`<span class="error">[[%form.error.required? &namespace=`site`]]</span>`]]
                <div class="clearfix"></div>
                <label>[[%form.label.email? &namespace=`site`]]</label><input type="text" name="EmailBegleitung" value="[[!+fi.Email]]" />[[!+fi.error.Email:notempty=`<span class="error">[[%form.error.email? &namespace=`site`]]</span>`]]
                <div class="clearfix"></div>
            </fieldset>
          </div>
          <fieldset>
            <p> <br />
            <label> </label><input type="checkbox" name="Teilnehmerliste" value="x"  [[!+fi.Teilnehmerliste:FormItIsChecked=`x`]]/>  [[%form.label.teilnehmerliste? &namespace=`site`]]
            <br /> </p>
          </fieldset>
          <label> </label><input type="submit" value="[[%form.button.submit? &namespace=`site`]]" />
        </form>
          • 3749
          • 24,544 Posts
          I don't see anything wrong.

          Try this in the custom hook (and double check the spelling of the custom hook name -- it's case-sensitive).


          $cm = $modx->getCacheManager();
          $cm->refresh;
          die('In Custom Hook');
          


          If that doesn't produce any output, try putting the die() line first.


          IIRC, hooks are only run after the form is successfully submitted, so you might want make sure the form works without the custom hook first.



          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 1778
            • 659 Posts
            Not sure of that but you don't mention any action in your form code...

            try
            <form action="[[~[[*id]]]]" method="post" >
            

            instead of
            <form method="post">
            


            Hope this helps
            Cheers