We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40349
    • 26 Posts
    I am having a FormItBuilder problem. I got my form to work, but whenever I fill it out and hit submit it redirects to my logo page and not the homepage.

    If you try it out I promise not to email or spam you.

    Here is my contact page www.aetoswebdesign.com/contact.html

    Here is the page it redirects to http://www.aetoswebdesign.com/logo-design.html

    Any Ideas?

    Here is my Snippet. I'm using the basic example

    <?php
    $snippetName='FormItBuilder_MyContactForm';
    require_once $modx->getOption('core_path',null,MODX_CORE_PATH).'components/formitbuilder/model/formitbuilder/FormItBuilder.class.php';
    if (function_exists('FormItBuilder_MyContactForm')===false) {
    function FormItBuilder_MyContactForm(modX &$modx, $snippetName) {
      
          
          
          
    //CREATE FORM ELEMENTS
    $o_fe_name      = new FormItBuilder_elementText('name_full','Your Name');
    $o_fe_email     = new FormItBuilder_elementText('email_address','Email Address');
    $o_fe_notes     = new FormItBuilder_elementTextArea('comments','Comments',5,30);
    $o_fe_buttSubmit    = new FormItBuilder_elementButton('submit','Submit Form','submit');
      
    //SET VALIDATION RULES
    $a_formRules=array();
    //Set required fields
    $a_formFields_required = array($o_fe_notes, $o_fe_name, $o_fe_email);
    foreach($a_formFields_required as $field){
        $a_formRules[] = new FormRule(FormRuleType::required,$field);
    }
    //make email field require a valid email address
    $a_formRules[] = new FormRule(FormRuleType::email, $o_fe_email, NULL, 'Please provide a valid email address');
      
    //CREATE FORM AND SETUP
    $o_form = new FormItBuilder($modx,'contactForm');
    $o_form->setHooks(array('spam','email','redirect'));
    $o_form->setRedirectDocument(5);
    $o_form->addRules($a_formRules);
    $o_form->setPostHookName($snippetName);
    $o_form->setEmailToAddress('[email protected]');
    $o_form->setEmailFromAddress('[[+email_address]]');
    $o_form->setEmailSubject('FormItBuilder Contact Form Submission - From: [[+name_full]]');
    $o_form->setEmailHeadHtml('<p>This is a response sent by [[+name_full]] using the contact us form:</p>');
    $o_form->setJqueryValidation(true);
      
    //ADD ELEMENTS TO THE FORM IN PREFERRED ORDER
    $o_form->addElements(
        array(
            $o_fe_name,$o_fe_email,$o_fe_notes,
            new FormItBuilder_htmlBlock('<hr class="formSpltter" />'),
            $o_fe_buttSubmit
        )
    );
      
    return $o_form;
          
      
      
      
    }
    }
    //Run the form construction function above
    $o_form = FormItBuilder_MyContactForm($modx, $snippetName);
    if (isset($outputType) === false) {
        //this same snippet was called via various other hooks
        return $o_form->processCoreHook($hook, $o_form);
    } else {
        //Final output for form
        return $o_form->output();
    }
    
      Wild Eagle Design

      www.wildeagledesign.com
      • 18270
      • 68 Posts
      What is the resourceID that you want to form to redirect to?

      The line
      $o_form->setRedirectDocument(5);

      controls where the user will redirect to once the form is filled out. It is a little hard to say without looking at the ModX setup you have there.
        • 40349
        • 26 Posts
        Thanks marcushouse. That solved my problem.

        For anyone else that is new to Modx and doing FormItBuilder the snippet you created "FormItBuilder_MyContactForm" look for
        $o_form->setRedirectDocument(5);


        Change the 5 to what ever page number of your resources you would like the form to redirect to.

        Again thank you marcushouse for solving this.
          Wild Eagle Design

          www.wildeagledesign.com