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

I need to use yii::app()->user->id in a form and to save the username in
can anyone convert this code into the yii framework? file name: text.php <form method='POST'
how do you covert this html code into the yii CHtml? <form aciton='site/qrcode' method='POST'>
How can I add support for plural forms in this Yii class: http://code.google.com/p/yii/source/browse/tags/1.1.8/framework/i18n/gettext/CGettextPoFile.php ?
in this tutorial of Yii framework http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#action i want to put my Actions from
I am working on creating website with Yii framework and I have a problem
I am semi-frustrated with this Yii CGridView problem and any help or guidance would
I have this small line of code in Yii Framework: array('username', 'unique', 'attributeName'=> 'username',
I’m having a problem getting the data from my database which I created to
Okay. I'm NOT asking which one is better. I know Yii is not better

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.