2011-02-07 4 views
0

나는 kohana 컨트롤러를 쓰고 있는데, 나는 끊임없이 불규칙한 오류가 발생했다.보기의 잘못된 인스턴스화에 관한 것 같지만 어디 있는지 알 수 없다. 내 컨트롤러 :보기 문제의 Kohana 컨트롤러 인스턴스화

<?php if (!defined('SYSPATH')) exit('No direct script access allowed'); 
/** 
    * Contact_Controller - Used for validating and sending emails from form. 
    * 
    */ 
    class Controller_Contact extends Controller 
    { 

    // public function __construct() 
    //{ 
     //parent::__construct(); 
    //} 

    public function action_index() 
    { 
     //Setup view without rendering 
     //Setup base view 
     $view = new View('template'); 

     //Setup header 
    // $view->header = new View('header'); 

     //Setup header title 
     //$view->header->title = 'Kohana Contact Form by Drew Douglass'; 

     //Setup content view 
     $view->content = new View('contact'); 

     //Setup footer view 
     //$view->footer = new View('footer'); 

     //Setup default form values so we can repopulate the form 
     $form = array 
     (
      'contact_name' => '', 
      'contact_email' => '', 
      'contact_subject' => '', 
      'contact_message' => '' 
     ); 

     //copy the form fields into the errors for later... 
     $errors = $form; 

     //Check to see if the form was submitted 
     if(isset($_POST['contact_submit'])) 
     { 
      //Add the rules we need to validate our form 
      $post = new Validation($_POST); 

      //filter the whitespace from beginning and ends of fields 
      $post->pre_filter('trim'); 

      //Add rules for contact_name 
      $post->add_rules('contact_name', 'required', 'standard_text', 'length[2,20]'); 

      //Add rules for contact_email 
      $post->add_rules('contact_email', 'required', 'email', 'email_domain'); 

      //add rules for subject 
      $post->add_rules('contact_subject', 'required', 'length[5,30]', 'standard_text'); 

      //Add rules for message 
      $post->add_rules('contact_message', 'required', 'standard_text'); 

      //If there were no errors... 
      if($post->validate()) 
      { 
       //Load the config file with our email address defaults 
       //This make our app more portable 
       $email_config = Kohana::config_load('email'); 

       //Send it and render the view with message. 
       $to = $email_config['default_email']; 
       $from = $this->input->post('contact_email'); 
       $subject = $this->input->post('contact_subject'); 
       $message = $this->input->post('contact_message'); 

       //Add some info to the end of the message for reference 
       $message .= "\n\n This message was sent to you from".$this->input->post('contact_name')." and the email given is ".$from; 

       if(email::send($to, $from, $subject, $message, TRUE)) 
       { 
        $view->content->set('form_values', $form); 
        $view->content->set('message', 'Your email was sent!'); 
        $view->render(TRUE); 
       } 
       else 
       { 
        die('We had a technical error, please try again.'); 
       } 
      } 

      //else we got errors... 
      else 
      { 
       //repopulate form values 
       $form = arr::overwrite($errors, $post->as_array()); 

       //setup the errors 
       $errors = arr::overwrite($errors, $post->errors('form_errors')); 

       //pass the form values and errors to the view 
       $view->content->set('errors', $errors); 
       $view->content->set('form_values', $form); 

       //Render the view with errors and values 
       $view->render(TRUE); 
      } 

     } 
     //form was not submitted, just show it. 
     else 
     { 
      $view->content->set('form_values', $form); 
      $view->render(TRUE); 
     } 

    } 

    } 

및 지속 에러 : Kohana_View_Exception [0] : 요청 된보기 1 왜 될 수

을 찾을 수 없습니다 ??

이이 Kohana2 구문이지만, Kohana3에, 렌더링 파라미터 오류 ( true => 1)를 일으키는 원인이되는 뷰 이름 문제는 $view->render(TRUE);에 당신에게

+0

Kohana v2 또는 Kohana v3의 경우인가요? v3이면 잘못된 문서를보고 있으며 [v3 문서] (http://kohanaframework.org/guide)를 읽어야합니다. – shadowhand

답변

관련 문제