开发者

my add form is not showing

I am developing Zend Framework App.

In my indexcontroller view views/scripts/index/index.phtml

<p><a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'add'));?>">Add new album</a></p>

in my browser is is outputting me only url path so it is not going to the add action. Here it is my add action in IndexController.php

 public function addAction()
    {
        // action body
        $form = new Application_Form_User();
        $form->submit->setLabel('Add');
        $this->view->form = $form;
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {
                $artist = $form->getValue('artist');
                $title = $form->getValue('title');
                $albums = new Application_Model_DbTable_Albums();
                $albums->addUser($artist, $title);
                $this->_helper->redirector('index');
            } else { 
                $form->populate($formData);
            }
        }
    }

and my add.phtml is

<?php
$this->title = "Add new album";
$this->headTitle($this->title);
echo $this->form ;
?>

why it is not going to add action. please suggest Edit More Info

and i am using this pdf to build the app http://akraba开发者_开发问答t.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf

In page No. 9 I am not getting where to put this line and is these lines are necessary or not ?

$view = new Zend_View();
$view->setScriptPath('/path/to/scripts');
echo $view->render('script.php');

and i haven't set the layout and CSS .but my listing from Database is coming but my add Dction is not working ? Please suggest why


I had added the following lines in the Bootstrap.php Because before i was trying to build REST API .

#$restRoute = new Zend_Rest_Route($frontController);
        # $frontController->getRouter()->addRoute('default', $restRoute);


Enable error reporting in your bootstrap or anywhere for that matter:

error_reporting(E_ALL);
ini_set('display_errors', true);

Or check your php error logs and post here what error message you got


It would be helpfull if you could give us your routing initialisation code (inside your Boostrap.php or application.ini).

At first look, it could be an url assemble contextual misuse.

The Zend_View_Helper_Url is route-contextual, aka its using the last route registered. So if you're on a page that uses a user-defined static route and not the default route, the helper will assemble the url with the user-defined route.

Try defining a route name in your view helper, like this (I assumed it's the default route) :

echo $this->url(array('controller'=>'index','action'=>'add'), 'default');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜