kohana在模态窗口中验证orm

时间:2022-12-27 19:38:44

I have controller action like this:

我有这样的控制器动作:

public function action_add() {
    $this->template->content = View::factory('frontend/content/add_video')
            ->bind('video', $video)
            ->bind('errors', $errors);
    $video = new Model_Video();
    if ($this->request->post()) {
        $video->values($this->request->post(), array('source', 'title', 'description'));
        try {
            $video->save();
        } catch (ORM_Validation_Exception $e) {
            $errors = $e->errors('video');
        }
    }
}

The view for this action is displayed in modal window. The window is openen with jquery. When the form is validated it is displayed on reguler window, not in the modal window. How to get the form valdates in modal? Should i use ajax call to get this to work? Please help.

此操作的视图显示在模态窗口中。窗口是用jquery操作的。表单验证后,它将显示在调节器窗口上,而不是显示在模态窗口中。如何在模态中获取表单valdates?我应该使用ajax调用来使其工作吗?请帮忙。

1 个解决方案

#1


0  

Try to use AJAX, but return only:

尝试使用AJAX,但仅返回:

    if($this->request->is_ajax()) {
        echo View::factory('frontend/content/add_video')
            ->bind('video', $video)
            ->bind('errors', $errors);
       exit;
    }

#1


0  

Try to use AJAX, but return only:

尝试使用AJAX,但仅返回:

    if($this->request->is_ajax()) {
        echo View::factory('frontend/content/add_video')
            ->bind('video', $video)
            ->bind('errors', $errors);
       exit;
    }