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

  • Home
  • SEARCH
  • 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 6717865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:54:08+00:00 2026-05-26T08:54:08+00:00

is it possible to override the methods in the yii model. for example i

  • 0

is it possible to override the methods in the yii model. for example i have a model name Books and i need to override all the rules written in the Model. now the Books model have 3 rules defined. what i do is make a new class BooksExt extends the Books model.

class BooksExt extends Books {
 public function rules() {
   return array();
   // i am not using the parent::rules() inside this. 
   // i dont need to use the rules for this model.
 }
 public function search() {
   return 'search override';
   // does this function also get override.
 }
}

does i write a blank rules() method removes all the rules and when i call

$model = new AccountsPrefferredSuppliersExt;
$model->search();

its printing search override. does it accept the rules as empty array.
friends can you just check and please responds.

thanks in advance.. have a nice day

  • 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-05-26T08:54:08+00:00Added an answer on May 26, 2026 at 8:54 am

    Yes, method rules() in BooksExt will return an empty array.
    Read about Class Hierachies And Overriding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why does Eclipse complain about @Override on interface methods? I have some
Possible Duplicate: Overriding equals and hashCode in Java All, I have defined my class
Is it possible to override the to_sentence method just for one model in my
Possible Duplicate: Protected in Interfaces In Java why cant I have protected methods in
In C# it is not possible to override a static method. Nevertheless I have
I know you can override the model methods but I was curious as to
I wondered if it is possible to disable/override all authorization attributes. On the development
In Java, it's possible to have methods inside an enum. Is there such possibility
Why is it not possible to override static methods? If possible, please use an
Possible Duplicate: Why are private virtual methods illegal in C#? I have the following

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.