Zend cant find a view from a folder where all the other views that i have been using so far have been found

StackOverflow https://stackoverflow.com/questions/21301259

Frage

Ok, so the problem goes as follows. i have a simple zend framework 2 app with a module router, controllers and views, i can view a table from a page, select to either add edit or delete an item from said table. as far as ADD and EDIT goes, the code works like a charm, now, when i want to DELETE something, it just outputs the following:

Zend\View\Renderer\PhpRenderer::render: Unable to render template "system/system/delete"; resolver could not resolve to a file

which makes absolutely NO SENSE as the file IS present on the folder, and avery other view URL that i visit using my browser works OK all views (ADD, EDIT, and INDEX) works OK, no problem at all, how can the program be telling me that a file, that is clearly present, just sitting there next to the other files i have been using so far "DOES NOT EXIST".

This is my folder estructure:

enter image description here

As you can see All view are in the same folder, all the other views that i call from url do open and work correctly. so why does this one not work ?.

My controller has the following delete action:

 public function deleteAction()
    {
        $id = (int) $this->params()->fromRoute('id', 0);
        if (!$id) {
            return $this->redirect()->toRoute('system');
        }

        $request = $this->getRequest();
        if ($request->isPost()) {
            $del = $request->getPost('del', 'No');

            if ($del == 'Yes') {
                $id = (int) $request->getPost('id');
                $this->getUserTable()->deleteUser($id);
            }

            // Redirect to list of System
            return $this->redirect()->toRoute('system');
        }

        return array(
            'id'    => $id,
            'system' => $this->getUserTable()->getUser($id)
        );
    }

And this is the code for the delete view:

<?php

$title = 'Delete user';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>

<div>
    <p>Are you sure that you want to delete  </p>
    <p> Username: '<?php echo $this->escapeHtml($system->username); ?>'
   First name: '<?php echo $this->escapeHtml($system->fisrt_name); ?>'?
    </p>
</div>

<?php
$url = $this->url('system', array(
    'action' => 'delete',
    'id'     => $this->id,
));
?>
<form action="<?php echo $url; ?>" method="post">
<div>
    <input type="hidden" name="id" value="<?php echo (int) $system->id; ?>" />
    <input type="submit" name="del" value="Yes" />
    <input type="submit" name="del" value="No" />
</div>
</form>

I keep looking at the code but i'm just helpless, i cant see to find any problem with it or why is this happening, which is making me feel realy mad, so i call upon your "l33t haxxor" coding knowledge to solve this one out.

Thanks in advance.

War es hilfreich?

Lösung

Well, i just found the error this is, quite funny actually, the problem, after just giving up all hope, was discovered after i said "well, im just gonna on the very least commit what i have 'till now to my svn repo" just to be greeted by an error from the SVN that read "invalid character '0x0a' on file delete.phtml" so apparently the reason why zend was not able to render the view was because in the file name, this mysterious character was added some how (i think this one corresponds to line break or something of the sort did not actually check). so, yay for svn ?.

So thanks for all your comments and sorry for wasting your time :/.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top