Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:28:36+00:00 2026-06-05T22:28:36+00:00

My Yii code not showing error summery before save movie in database.. what’s the

  • 0

My Yii code not showing error summery before save movie in database.. what’s the problem ?

Form code: http://jsfiddle.net/SRMzc/

it’s actionCreate function:

  public function actionCreateM()
    {
        $model=new Movie;

        if(isset($_POST['Movie']))
        {
            $model->attributes=$_POST['Movie'];

            $photos = CUploadedFile::getInstancesByName('photo');

            if (isset($_POST['Movie']['youtube_id'])){
                $model->youtube_id=$_POST['Movie']['youtube_id'];
            }



            if (isset($_POST['Movie']['poster_uri'])){
                $file=CUploadedFile::getInstance($model,'poster_uri');
                if(isset($file)){
                    $model->poster_uri = $model->short_title .'_poster.' . $file->extensionName;
                }
            }

            if($model->save()).......

Rules:

from movie model

public function rules()
{
    // NOTE: you should only define rules for those attributes that
    // will receive user inputs.
    return array(
        array('title, short_title, year, imdb_rate, rate, cast, director, summary, release_date, duration, views, featured', 'required'),
        array('views, featured, available_status', 'numerical', 'integerOnly'=>true),
        array('title, short_title, genre, director', 'length', 'max'=>64),
        array('poster_uri', 'file', 'types'=>'jpg, gif, png', 'allowEmpty' => true),
        array('cast', 'length', 'max'=>256),
        array('year', 'length', 'max'=>4),
        array('lang', 'length', 'max'=>2),
        array('imdb_rate', 'length', 'max'=>3),
        array('rate', 'length', 'max'=>5),
        array('duration', 'length', 'max'=>11),
        // The following rule is used by search().
        // Please remove those attributes that should not be searched.
        array('title, short_title, views, featured, available_status', 'safe', 'on'=>'search'),
    );
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:28:38+00:00Added an answer on June 5, 2026 at 10:28 pm

    Error summary works with ajax. you need to set enableAjaxValidation to true in your form definition. then you need to track that ajax call in action and validate your model and then echo the errors (check create action in Yii blog demo app for more details).

    If you need to validate the code in PHP try following

    if(!$model->save())
    {
        print_r($model->getErrors());
    }
    

    or

    if(!$model->validate())
    {
        print_r($model->getErrors());
    }
    else 
    {
        $model->save();
    }
    

    validation code goes something like this

    if(isset($_POST['ajax']) && $_POST['ajax']==='comment-form')
    {
        echo CActiveForm::validate($comment);
        Yii::app()->end();
    }
    

    Edit:- You don’t really need to enable ajax to get validation summary. you can have php code for the same, something like this.

    if($model->validate())
    {
        $model->save();
        //render some other view here
    }
    $this->render('Your_update_or_create_view');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im creating a Yii app where i will save images into the database. Now
PROBLEM 1: When I try to save() any Yii Model, it updates all fields
I have created an ajax link(CHTML::ajaxLink) in Yii framework(not ajax form submit button) that
By taking into consideration the following code snipped: if('<?= Yii::app()->controller->action->id?>' == 'create'){ $(#Event_name).focusout(function(){ $.ajax({
After running into the Yii asset engine I've read the official documentation (http://www.yiiframework.com/wiki/148/understanding-assets/). I
I'm hosting a Yii app on shared-host with some my friend, and keep database
I'm new using Yii framework. I show a list a checkbox. But it's not
I want to display form with custom property mainly enctype in YII. I have
I have tried to connect PostgreSQL with Yii but is is showing CDbConnection failed
I am using the following code to publish my css file to assets. Yii::app()->clientScript->registerCssFile(

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.