O'Reilly logo

Web Application Development with Yii 2 and PHP by Jeffrey Winesett, Mark Safronov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the user interface

With the CustomersController able to convert between domain models and active records, we move to the actual user interface pages at last.

The Add New Customer UI

What should Controller do for us when we arrive at the /customer/add URL? Well, it should just render the UI for us:

    public function actionAdd()
    {
        $this->render('add');
    }

That's right, that's all. This code relies on the important convention of Yii describing from where the controller should get its views. Basically, if we have CustomersController, then its views are expected to be in the views/customer subdirectory. So, when we render something called add here, we're referring to the file views/customer/add.php. Let's create it.

What do we want on this page? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required