Yii Tutorial
Yii Useful Resources
Selected Reading
- Gii – Generating Module
- Gii – Generating Controller
- Gii – Creating a Model
- Yii - Gii
- Yii - Localization
- Yii - Authorization
- Yii - Authentication
- Yii - Error Handling
- Yii - Logging
- Yii - Aliases
- Yii - Fragment Caching
- Yii - Caching
- Yii - Testing
- Yii - Fields
- Yii - RESTful APIs in Action
- Yii - RESTful APIs
- Yii - Theming
- Yii - Database Migration
- Yii - Active Record
- Yii - Query Builder
- Yii - Data Access Objects
- Yii - Database Access
- Yii - Dependency Injection
- Yii - Configurations
- Yii - Creating a Behavior
- Yii - Behaviors
- Yii - Creating Event
- Yii - Events
- Yii - GridView Widget
- Yii - ListView Widget
- Yii - Data Widgets
- Yii - Data Providers
- Yii - Properties
- Yii - Sorting
- Yii - Pagination
- Yii - Formatting
- Yii - Files Upload
- Yii - Using Cookies
- Yii - Cookies
- Yii - Using Flash Data
- Yii - Sessions
- Yii - AJAX Validation
- Yii - Ad Hoc Validation
- Yii - Validation
- Yii - HTML Forms
- Yii - Rules of URL
- Yii - URL Routing
- Yii - URL Formats
- Yii - Responses
- Yii - HTTP Requests
- Yii - Creating Extensions
- Yii - Extensions
- Yii - Asset Conversion
- Yii - Assets
- Yii - Layouts
- Yii - Views
- Yii - Modules
- Yii - Widgets
- Yii - Models
- Yii - Using Actions
- Yii - Using Controllers
- Yii - Controllers
- Yii - Entry Scripts
- Yii - Application Structure
- Yii - Create Page
- Yii - Installation
- Yii - Overview
- Yii - Home
Yii Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Gii – Generating Controller
Gii - Generating Controller
Let us see how to generate a Controller.
Step 1 − To generate a controller with several actions, open the controller generator interface fill in the form.
Step 2 − Then, cpck the “Preview” button and “Generate”. The CustomController.php file with index, hello, and world actions will be generated in the controllers folder.
<?php namespace appcontrollers; class CustomController extends yiiwebController { pubpc function actionHello() { return $this->render( hello ); } pubpc function actionIndex() { return $this->render( index ); } pubpc function actionWorld() { return $this->render( world ); } } ?>
Form Generation
Step 1 − To generate a view file from an existing model, open the form generation interface and fill in the form.
Then, cpck the “Preview” button and “Generate”. The customview view file will be generated in the view folder.
Step 2 − To display it, add a new method to the CustomController.
pubpc function actionView() { $model = new MyUser(); return $this->render( /customview , [ model => $model, ]); }
Step 3 − To see the generated view file, open the URL http://localhost:8080/index.php?r=custom/view.
Advertisements