我们如何重定向到kohana中的特定div

时间:2021-05-21 20:29:46

I'm using Kohana framework for my project,I've very lengthy login page.Top of the page shows some static description,contains nearly 200 lines of text, while bottom have sign-up and sign-in forms,when an error occurs the fields will be popup with appropriate error messages,but template loads from top,So user unable to see the error messages.To achieve this how can I redirect user to error div when error occurs ? I'm changing template value as followsif($form_error) $this->template = 'login#error_div'; but its not working

我正在为我的项目使用Kohana框架,我的登录页面非常冗长。页面顶部显示一些静态描述,包含近200行文本,而底部有注册和登录表单,当发生错误时这些字段将弹出相应的错误消息,但模板从顶部加载,因此用户无法看到错误消息。为实现此目的,如何在发生错误时将用户重定向到错误div?我正在更改模板值如下($ form_error)$ this-> template ='login#error_div';但它不起作用

Thanks in advance

提前致谢

1 个解决方案

#1


0  

You need to redirect the user to the page with the hash, not set the template's source to be it, which in that context doesn't make sense.

您需要将用户重定向到带有哈希的页面,而不是将模板的源设置为它,在该上下文中没有意义。

if ($form_error) {
    $this->request->redirect("whatever#error_div");
}

You may also want to use a better id for your errors, maybe errors, otherwise you are leaking implementation details to the URL for no benefit.

您可能还希望为错误使用更好的ID,也许是错误,否则您将实现详细信息泄漏到URL中,没有任何好处。

#1


0  

You need to redirect the user to the page with the hash, not set the template's source to be it, which in that context doesn't make sense.

您需要将用户重定向到带有哈希的页面,而不是将模板的源设置为它,在该上下文中没有意义。

if ($form_error) {
    $this->request->redirect("whatever#error_div");
}

You may also want to use a better id for your errors, maybe errors, otherwise you are leaking implementation details to the URL for no benefit.

您可能还希望为错误使用更好的ID,也许是错误,否则您将实现详细信息泄漏到URL中,没有任何好处。