2014-09-29 2 views
0

zf2에서 파일 오류를 렌더링 할 수 없습니다.
일치하는 요구 사항에 따라 데이터를 검색해야하지만 오류가 발생하는 결혼 사이트 프로젝트를 진행하고 있습니다. 다음은 내 코드입니다 :Zend View Renderer PhpRenderer :: render : 템플릿을 렌더링 할 수 없습니다.

Zend\View\Renderer\PhpRenderer::render: Unable to render template "project/search/process"; resolver could not resolve to a file

: 프로젝트 /보기/프로젝트/검색

//SearchController.php in Project/src/Project/Controller 
public function processAction() 
{ 
if (!$this->request->isPost()) { 
return $this->redirect()->toRoute(NULL , 
array('controller' => 'search', 
'action' => 'index' 
)); 
} 

$post = $this->request->getPost(); 
$dbAdapter=$this->getServiceLocator()->get('Zend\Db\Adapter\Adapter'); 
$form = new SearchForm($dbAdapter); 
//$inputFilter = new RegisterFilter(); 
//$form->setInputFilter($inputFilter); 
$form->setData($post); 
if (!$form->isValid()) { 
$model = new ViewModel(array(
'error' => true, 
'form' => $form, 
)); 
$model->setTemplate('project/search/index'); 
return $model; 
} 

$ageto = $this->getRequest()->getPost('ageto'); 
$agefrom = $this->getRequest()->getPost('agefrom'); 
$heightfrom = $this->getRequest()->getPost('heightfrom'); 
$heightto = $this->getRequest()->getPost('heightto'); 
$educationid = $this->getRequest()->getPost('educationid'); 
$cityid = $this->getRequest()->getPost('cityid'); 
$complexionid = $this->getRequest()->getPost('complexionid'); 
$religioncode = $this->getRequest()->getPost('religioncode'); 


$sql="SELECT * FROM projects WHERE YEAR(CURDATE())-YEAR(dob) BETWEEN ".$agefrom. " AND ".$ageto; 
$sql.=" and heightcode BETWEEN ". $heightfrom." AND ". $heightto." and religioncode = ".$religioncode; 

$sm = $this->getServiceLocator(); 
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); 
$statement = $dbAdapter->query($sql); 

$result = $statement->execute(); 
$num=count($result); 
if($num==0) 
{ 
echo "No Matches Found"; 
} 
else 
{ 
$result = $statement->execute(); 
$selectData = array(); 

foreach ($result as $res) { 

     $selectData=$res; 
    } 
return $selectData; 
    } 

return $this->redirect()->toRoute(NULL , array(
'controller' => 'search', 
'action' => 'confirm' 
)); 
} 

public function confirmAction() 
{ 
    $viewModel = new ViewModel(); 
return $viewModel; 
} 

index.phtml

<html> 
<head><link rel="stylesheet" href="/css/demo.css" type="text/css" ></head> 
<section class="search"> 
<p> Welcome! </p> 

<h2>Search Form</h2> 
<?php if ($this->error): ?> 

<p class="error"> 
There were one or more issues with your submission. 
Please correct them as 
indicated below. 
</p> 
<?php endif ?> 
<?php 

$form = $this->form; 
$form->prepare(); 
$form->setAttribute('action', $this->url(NULL,array('controller'=>'Search', 'action' =>'process'))); 
$form->setAttribute('method', 'post'); 
$form->setAttribute('enctype','multipart/form-data'); 
echo $this->form()->openTag($form); 
?> 


<body> 
<div align="left"> 
<table align="left" cellpadding="6"> 
<tr><th>Age:</th> 
<td><?php 
echo $this->formElement($form->get('agefrom')); 
?> 
&nbsp;&nbsp;<b>to </b>&nbsp;&nbsp; 
<?php echo $this->formElement($form->get('ageto')); 
?></td></tr> 
<tr><th>Height:</th> 
<td><?php 
echo $this->formElement($form->get('heightfrom')); 
?> 
&nbsp;&nbsp;<b>to</b> &nbsp;&nbsp; 
<?php echo $this->formElement($form->get('heightto')); 
?></td></tr> 
<tr><th>Education:</th> 
<td><?php 
echo $this->formElement($form->get('educationid')); 
echo $this->formElementErrors($form->get('educationid'));?></td></tr> 

<tr><th>City:</th> 
<td><?php 
echo $this->formElement($form->get('cityid')); 
echo $this->formElementErrors($form->get('cityid'));?></td></tr> 

<th>Complexion:</th> 
<td><?php 
echo $this->formElement($form->get('complexionid')); 
echo $this->formElementErrors($form->get('complexionid'));?></td></tr> 

<tr><th>Religion:</th> 
<td><?php 
echo $this->formElement($form->get('religioncode')); 
echo $this->formElementErrors($form->get('religioncode'));?></td></tr> 

<tr> 
<td><?php 
echo $this->formElement($form->get('submit')); 
echo $this->formElementErrors($form->get('submit')); 
?></td></tr> 
<?php echo $this->form()->closeTag() ?> 


</table> 
</section> 
</div> 

하지만 클릭 후 내가 렌더링 오류를 받고 있어요 제출

Module.config.php

<?php 
return array(
'controllers' => array(
'invokables' => array(
'Project\Controller\Index' => 
'Project\Controller\IndexController', 
'Project\Controller\Register' => 
'Project\Controller\RegisterController', 
'Project\Controller\Login' => 
'Project\Controller\LoginController', 
'Project\Controller\Search' => 
'Project\Controller\SearchController', 
), 
), 


'router' => array(
'routes' => array(
'project' => array(
'type' => 'Literal', 
'options' => array(

'route' => '/project', 
'defaults' => array(

'__NAMESPACE__' => 'Project\Controller', 
'controller' => 'Index', 
'action' => 'index', 
), 
), 
'may_terminate' => true, 
'child_routes' => array(
// specific routes. 
'default' => array(
'type' => 'Segment', 
'options' => array(
'route' => 
'/[:controller[/:action]]', 
'constraints' => array(
'controller' => 
'[a-zA-Z][a-zA-Z0-9_-]*', 
'action' => 
'[a-zA-Z][a-zA-Z0-9_-]*', 
), 
'defaults' => array(
), 
), 
), 
), 
), 
), 
), 
'view_manager' => array(
'template_path_stack' => array(
'project' => __DIR__ . '/../view', 
), 

    'strategies' => array(
      'ViewJsonStrategy', 
    ), 




), 
); 

답변

2

Project/view/project/search/process.phtml 파일을 만드시겠습니까?

+0

아니요 Project/view/project/search/index.phtml 및 Project/view/project/search/confirm.phtml 파일이 없습니다. – prachi

+0

"project/search/process"템플릿을 렌더링 할 수 없습니다. 오류로 인해 process.phtml이 없습니다! – webDEVILopers

+0

하지만 processAction 및 confirmAction 메서드를 통해 confirm.phtml을 렌더링하고 process.phtml이 아닌 – prachi

관련 문제