Book Image

Instant Building Multi-Page Forms with Yii How-to

By : Uday Sawant
Book Image

Instant Building Multi-Page Forms with Yii How-to

By: Uday Sawant

Overview of this book

Yii is a high-performance PHP framework for rapid web application development. It is well-designed, well-supported, easy to learn, and easy to maintain. Forms are the basic method used to collect information on the Internet, and in cases like user registration and payment process, there's a lot of data to be presented and the lists can get lengthy. Instant Building Multi-Page Forms with Yii is a simple and descriptive how-to that provides step-by-step recipes to help you in converting your lengthy forms into short, interactive forms. It will guide you through the inbuilt features of Yii framework to help you with this complex job. The book starts with the basics of Yii and will guide you through creating simple forms before then converting your simple forms into multi-page forms. It will use the capabilities of Yii to ease the tasks required to do this. Yii eases your work by providing options like database connectivity. We will also take a look at the automated code generation capabilities of Yii in generating forms and necessary CRUD operations, as well as looking at how to divide a single long form into multiple views with same controller/action, and then add form validations and AJAX support to the forms. We will also cover the upload process and how to customise Yii's looks.
Table of Contents (7 chapters)

Getting started with Yii (Simple)


We will start with the basic setup of the Yii environment; that is, connecting to a database server and automated generation of Gii and forms with Yii.

Getting ready

This book assumes that you are familiar with the PHP development environment and have a basic development environment set up for PHP application development.

Download the Yii framework from http://www.yiiframework.com/ and extract its framework folder outside your Public_html folder or web root folder. Your application will refer to Yii Bootstrap, Yii.php, located inside the Framework folder.

How to do it...

Let's move to creating the web application. We will use the command-line utility of Yii to generate the new Yii application.

  1. Open the command prompt or a console under Linux.

  2. Change the current folder to where the framework has been extracted and enter the following command:

    yii> framework/yiic  webapp  webRoot/sampleapp 
  3. Access the newly generated application at http://localhost/sampleapp/index.php.

How it works...

The command will ask you for confirmation and will then generate the basic structure of the Yii application. You can find the details of the directory structure at http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/.

Yii has already created a few simple pages with a Contact Us form and a Login form. Following is the screenshot of the default Contact Us form: