Revision #6                                    has been created by 
 Maurizio Domba Cerin                                    on May 13, 2012, 6:48:10 PM with the memo:
                                
                                
                                    styled the code                                
                                                                    « previous (#5)                                                                                                    next (#7) »                                                            
                            Changes
                            
    Title
    unchanged
    Simple 5 minute form walkthrough
    Category
    unchanged
    Tutorials
    Yii version
    unchanged
    
    Tags
    unchanged
    Forms, tutorial
    Content
    changed
    [...]
When you come to create the form Yii will automatically create validation rules based on your table structure - so in the case below Yii won't validate a null title or a title which is more than 5 characters.
~~~
CREATE TABLE tbl_details (
        uniq VARCHAR(20) NOT NULL PRIMARY KEY,
    
    date_in date DEFAULT NULL, 
    
    time_in time DEFAULT NULL, 
    
    title VARCHAR(5) NOT NULL,
        first VARCHAR(30) DEFAULT NULL,
    
    last VARCHAR(30) DEFAULT NULL,
        email VARCHAR(60) DEFAULT NULL
);
~~~[...]
* Lists all models.
*/
 
public function actionIndex()
        {   
                $model=new Details;
                if(isset($_POST['Details']))
    
            {   
 
                {   
 
        $model->attributes=$_POST['Details'];
                     if ($model->save())
                {   
            print "Your model has been saved";
die();  
	        }   
 
         die();  
 
        }   
 
        }    
 
    $this->render('details_form',array(
            
            'model'=>$model,
        
        )); 
 
        )); 
 
}   
~~~
Visit the url below to view your form.
~~~[...]