Returning Views from Controllers

Yii 2 App Dev Book Errors chapter 2

In chapter 2 (p50) we start to build the user interface for the project, but the actions in the controller are not given correctly in the book. This is already noted on the packtpub site in the book errata but I'm adding it here for completeness.

This post is specific to the 'Web Application Development with Yii 2 and PHP' book

On pages 50 and 51 we add the actionAdd() function to the customer controller. The $this->render needs to be returned in the function making the final code on page 51:

public function actionAdd()
    $customer = new CustomerRecord;
    $phone = new PhoneRecord;
    return $this->render('add', compact('customer', 'phone'));

Blog Comments powered by Disqus.