修改Webform模块

发布于 2024-08-23 16:01:16 字数 538 浏览 5 评论 0原文

我需要一些帮助来修改 Webform 模块,以便它可以适用于我的项目。 我现在使用 Webform 来处理单页、基本表单,效果非常好。 我需要能够获取多个网络表单并根据用户所做的一些初始选择将它们串在一起。 让我举个例子。

用户被发送到“一般信息”网络表单,他们在其中输入姓名和生日等信息。还有 3 个带有复选框的问题,分别是:

“您有房子吗”

“您有汽车吗”

“您有孩子吗”

用户可以选择全部、部分或不选择任何选项。根据用户的选择,一旦他们按下提交按钮,他们将被发送到“房屋表格”、“汽车表格”和/或“儿童表格”。

当他们填写完所有表格后,系统会向管理员发送一封电子邮件,就像现在的网络表单一样。该信息不需要存储在网站的数据库中,电子邮件就足够了。

那么,关于如何做到这一点有什么建议吗?除了 Webform 之外还有其他更合适的吗?或者(如果我超级幸运)是否已经存在一个可以满足我需要的模块?

I need some help modifying the Webform Module so that it can work for my project.
I use Webform right now for single page, basic forms, and it works wonderfully.
What I need to be able to take multiple webforms and string them together based on some initial selections a user makes.
Let me give an example.

The user is sent to a "General Information" webform, where they put in things like name and birthday. There are also 3 questions with check-boxes which are:

"Do you have a house"

"Do you have a car"

"Do you have children"

The user can select all, some, or none of the options. Based on what the user selects, once they press the submit button, they will be sent to the "House form", "Car form", and/or "Children form".

When they're done filling out all the forms, an email is sent to the admin just like webforms does now. The information does not need to be stored on the website in the database, the email is sufficient.

So, any suggestions on how to do this? Would something else besides Webform be more appropriate? Or (if I'm super lucky) does a module which does what I need already exist?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

飞烟轻若梦 2024-08-30 16:01:16

为什么不简单地根据需要显示或隐藏表单元素,而不是重定向到其他可能多个后续表单?

使用以下 (x)html:

<form enctype="form/multipart" method="post" action="">

    <fieldset>

        <legend>Cars:</legend>

        <label for="cars">Do you have one, or more, cars?</label><input name="cars" id="cars" class="test" type="checkbox" />
        <fieldset class="subSection" id="cars">
            <input type="radio" name="numCars" value="1" />One
            <input type="radio" name="numCars" value="2" />Two
            <input type="radio" name="numCars" value="3" />Three
        </fieldset>

    </fieldset>

    <fieldset>

        <legend>Children:</legend>

        <label for="kids">Do you have one, or more, children</label><input name="kids" id="kids" class="test" type="checkbox" />
        <fieldset class="subSection" id="kids">
            <input type="radio" name="numKids" value="1" />One
            <input type="radio" name="numKids" value="2" />Two
            <input type="radio" name="numKids" value="3" />Three
        </fieldset>

    </fieldset>

    <fieldset>

        <legend>Houses:</legend>

        <label for="houses">Do you have one, or more, houses</label><input name="houses" id="houses" class="test" type="checkbox" />
        <fieldset class="subSection" id="houses">
            <input type="radio" name="numHouses" value="1" />One
            <input type="radio" name="numHouses" value="2" />Two
            <input type="radio" name="numHouses" value="3" />Three
        </fieldset>

    </fieldset>

</form>

和 jQuery(可以整理,但我自己还是新手......所以恐怕只是“概念证明”):

$(document).ready(
    function() {
        // hide the sub-sections
        $('fieldset.subSection').hide();

        // show subsections onClick of the .test checkboxes
        $('input.test').click(
            function() {
                $(this).next('fieldset.subSection').slideToggle('slow');
            }
        )
    }
);

现场演示当前位于:< a href="http://davidrhysthomas.co.uk/so/subForms.html" rel="nofollow noreferrer" title="链接到演示。">http://davidrhysthomas.co.uk/so/subForms.html

Why not simply show, or hide, the form elements as required, rather than redirect to other, potentially-multiple subsequent, forms?

Using the following (x)html:

<form enctype="form/multipart" method="post" action="">

    <fieldset>

        <legend>Cars:</legend>

        <label for="cars">Do you have one, or more, cars?</label><input name="cars" id="cars" class="test" type="checkbox" />
        <fieldset class="subSection" id="cars">
            <input type="radio" name="numCars" value="1" />One
            <input type="radio" name="numCars" value="2" />Two
            <input type="radio" name="numCars" value="3" />Three
        </fieldset>

    </fieldset>

    <fieldset>

        <legend>Children:</legend>

        <label for="kids">Do you have one, or more, children</label><input name="kids" id="kids" class="test" type="checkbox" />
        <fieldset class="subSection" id="kids">
            <input type="radio" name="numKids" value="1" />One
            <input type="radio" name="numKids" value="2" />Two
            <input type="radio" name="numKids" value="3" />Three
        </fieldset>

    </fieldset>

    <fieldset>

        <legend>Houses:</legend>

        <label for="houses">Do you have one, or more, houses</label><input name="houses" id="houses" class="test" type="checkbox" />
        <fieldset class="subSection" id="houses">
            <input type="radio" name="numHouses" value="1" />One
            <input type="radio" name="numHouses" value="2" />Two
            <input type="radio" name="numHouses" value="3" />Three
        </fieldset>

    </fieldset>

</form>

And the jQuery (which could be tidied, but I'm still new at it myself...so 'proof of concept' only, I'm afraid):

$(document).ready(
    function() {
        // hide the sub-sections
        $('fieldset.subSection').hide();

        // show subsections onClick of the .test checkboxes
        $('input.test').click(
            function() {
                $(this).next('fieldset.subSection').slideToggle('slow');
            }
        )
    }
);

Live demo currently located at: http://davidrhysthomas.co.uk/so/subForms.html

我不会写诗 2024-08-30 16:01:16

条件字段是即将推出的 Webform 版本 3 的一项功能。请参阅相关的 问题测试版于两周前发布。

Conditional fields are a feature of the upcoming Webform version 3. See the related issue and the beta version that was released two weeks ago.

别忘他 2024-08-30 16:01:16

创建自定义模块,它将捕获通过 hook_nodeapi 的提交并重定向到正确的表单或页面...

Create custom module, that will catch submit via hook_nodeapi and redirect to proper form or page...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文