O'Reilly logo

Yii Rapid Application Development Hotshot by James R. Hamilton III, Lauren J. O'Meara

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

Integrating with Comic Vine – The Search, Part 2

We have laid the groundwork for our Comic Vine volume search. Now we will add a search form. We will use the CActiveForm widget.

Engage Thrusters

  1. Create a model for the widget to use. Create the file protected/models/CvSearchForm.php with the following contents:
    <?php
    class CvSearchForm extends CFormModel {
      public $query;
      
      public function rules()
      {
        return array(
          array('query', 'required'),
        );
      }
    
      public function attributeLabels()
      {
        return array(
          'query'=>'Title Search',
        );
      }
    }

    Our needs from the model are minimal and this should take care of it.

  2. Now add this to the controller (be sure to change the if condition to an elseif).
        $model = new CvSearchForm();
        if (isset($_POST['CvSearchForm']))
        {
     $itemList ...

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