好吧,问题是我创建了一个只有一页的html网站,其中有多个部分代表所有页面。我遇到的问题是form I t联系人表单工作正常,但我无法让它重定向到正确的id。因此,一旦我提交表单,它会将我带回页面顶部。有什么想法吗?查看下面的表格电话:

[[!FormIt?
    &hooks=`email`
    &emailFrom=`[email protected]`
    &emailTpl=`emailChunk`
    &emailTo=`[[+email]]`
    &redirectTo=`http://myurl/index.php#contact`
    &emailSubject=`BHT Website Inquiry`
    &validate=`name:required,
    email:email:required,
    comment:required:stripTags`
    &successMessage=`
    <div class="alert alert-success marginTop25">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <h4>Thank you! Your inquiry has been submitted successfully.</h4>
    </div>
    `
    &validationErrorMessage=`
    <div class="alert alert-error">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <ul>
            [[!+fi.error.name:!empty=`
            <li><a href="[[~[[*id]]]]#name">Name is a required field</a></li>
            `]]
            [[!+fi.error.email:!empty=`
            <li><a href="[[~[[*id]]]]#email">Email is a required field</a></li>
            `]]
            [[!+fi.error.comment:!empty=`
            <li><a href="[[~[[*id]]]]#comment">Comment is a required field</a></li>
            `]]
        </ul>
    </div>
    `
]]

[[!+fi.validation_error_message:!empty=`
    <div class="alert alert-error marginTop25">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <ul>
            [[!+fi.error.name:!empty=`
            <li><a href="[[~[[*id]]]]#name">Name is a required field</a></li>
            `]]
            [[!+fi.error.email:!empty=`
            <li><a href="[[~[[*id]]]]#email">Email is a required field</a></li>
            `]]
            [[!+fi.error.comment:!empty=`
            <li><a href="[[~[[*id]]]]#comment">Comment is a required field</a></li>
            `]]
        </ul>
    </div>
`]]

[[!+fi.successMessage]]
<form action="[[~[[*id]]]]" method="post">
    <div class="[[!+fi.error.name:notempty=`control-group error`]]" id="name">
        <label for="name">Name:

            <div class="controls">
                <input type="text" name="name" value="[[!+fi.name]]" class="input-block-level">
            </div>
        </label>
    </div>

    <div class="[[!+fi.error.email:notempty=`control-group error`]]" id="email">
        <label for="email">Email:

            <div class="controls">
                <input type="text" name="email" value="[[!+fi.email]]" class="input-block-level">
            </div>
        </label>
    </div>

    <div class="[[!+fi.error.comment:notempty=`control-group error`]]" id="comment">
        <label for="comment">Comment: </label>

        <div class="controls">
            <textarea name="comment" cols="30" rows="10" value="[[!+fi.comment]]" class="input-block-level"></textarea>
        </div>
    </div>

    <input type="submit" value="Submit" class="btn btn-primary">
</form>

最佳答案

你需要指定重定向钩子,我不认为formit会接受url,文档说你需要一个页面id,上面说,如果你需要向url添加一个查询字符串,你可能需要编写一个使用makeUrl&/或sendrirect的小post钩子。
http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/class-reference/modx/modx.makeurl
尽管您可能无法创建带有“联系人”位的url。。。。
http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/class-reference/modx/modx.sendredirect
类似于:

$url = 'http://myurl/index.php#contact';
$modx->sendRedirect($url);

关于jquery - 如何使用ModX Revolution使FormIt重定向到网页ID(即www.myurl.com/index.php#contact)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23175515/

10-09 23:09