magento - 当两个表单集成在同一个 magento 页面中时显示错误消息

标签 magento

我有登录表单和注册表单,集成在同一页面中。即,在登录页面本身。

我在显示错误消息时遇到问题,好像任何一种表单中发生错误,然后错误消息都会显示在登录和注册部分中。

例如,假设我们提供了错误的登录数据进行登录,则错误消息将显示在登录表单和注册表单的顶部,因为这两个表单位于同一页面中。

如果我们尝试使用已经存在的电子邮件地址进行注册,那么还会在登录表单和注册表单的顶部显示错误消息,指出电子邮件已存在。

我的要求是只需要在相应的表单中显示错误消息。

为了将登录和注册表单集成到登录页面本身,我更改了文件 \app\design\frontend\anz\default\layout\customer.xml ,它是如下

客户登录页面的布局

<customer_account_login translate="label">
    <label>Customer Account Login Form</label>
    <!-- Mage_Customer -->
    <remove name="right"/>
    <remove name="left"/>

    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <reference name="content">
        <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
    </reference>


    <!-- Mage_Customer -->
    <remove name="right"/>
    <remove name="left"/>
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <block type="page/html_wrapper" name="customer.form.register.fields.before" translate="label">
        <label>Form Fields Before</label>
        <!--action method="setMayBeInvisible"><value>1</value></action-->
        <action method="setElementClass"><value>rewards</value></action>
    </block>
    <block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_user_attributes">
        <action method="setFormCode"><code>customer_account_create</code></action>
        <action method="setEntityModelClass"><code>customer/customer</code></action>
    </block>
    <block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_address_user_attributes">
        <action method="setFormCode"><code>customer_register_address</code></action>
        <action method="setEntityModelClass"><code>customer/address</code></action>
    </block>
    <reference name="content">
        <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
            <action method="append"><block>customer.form.register.fields.before</block><alias>form_fields_before</alias></action>
            <action method="append"><block>customer_form_user_attributes</block></action>
            <action method="append"><block>customer_form_address_user_attributes</block></action>
        </block>
    </reference>
    <update handle="customer_form_template_handle"/>



</customer_account_login>

我是 magento 的新手。任何帮助将不胜感激。

最佳答案

我稍微改变了你的代码。请告诉我您的表单在哪里呈现?

<customer_account_login translate="label">
    <label>Customer Account Login Form</label>
    <!-- Mage_Customer -->
    <remove name="right"/>
    <remove name="left"/>
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>

    <block type="page/html_wrapper" name="customer.form.register.fields.before" translate="label">
        <label>Form Fields Before</label>
        <!--action method="setMayBeInvisible"><value>1</value></action-->
        <action method="setElementClass"><value>rewards</value></action>
    </block>
    <block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_user_attributes">
        <action method="setFormCode"><code>customer_account_create</code></action>
        <action method="setEntityModelClass"><code>customer/customer</code></action>
    </block>
    <block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_address_user_attributes">
        <action method="setFormCode"><code>customer_register_address</code></action>
        <action method="setEntityModelClass"><code>customer/address</code></action>
    </block>
    <reference name="content">
        <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
        <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
            <action method="append"><block>customer.form.register.fields.before</block><alias>form_fields_before</alias></action>
            <action method="append"><block>customer_form_user_attributes</block></action>
            <action method="append"><block>customer_form_address_user_attributes</block></action>
        </block>
    </reference>
    <update handle="customer_form_template_handle"/>
</customer_account_login>

关于magento - 当两个表单集成在同一个 magento 页面中时显示错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8253418/

相关文章:

Magento XML - cms_index_index 和 cms_index_defaultindex 的区别

Magento 1.7 向集合过滤器添加多个属性

Magento 从 1.4.0.1 升级 1.9.2.3 : Upgrade installer thrown error: Cannot add foreign key constraint

java - Magento 类覆盖设计模式的正式名称?

javascript - 如何在页面上查找字符串然后使用 jQuery 将样式添加到特定的 div?

php - magento 全文搜索不适用于 Live

Magento 增加了前端的图像尺寸

php - Magento 在分层导航中使用所有属性

security - 如果手动安装magento中的安全补丁可以看到吗?

Magento 设置不保存客户属性选项值?