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 8646899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:55:53+00:00 2026-06-12T12:55:53+00:00

I have a model for User and a model for Notes. User Model: class

  • 0

I have a model for User and a model for Notes.

User Model:

class User extends AppModel {
var $name = 'User';
var $hasMany = array(
'Note' 
    );
 }

User Controller:

public function notesview()
  {
  $allnotes = $this->User->Note->find('all', array('order'=>'Note.created DESC'));
  } 

View Element:

$allnotes = $this->requestAction(array('controller'=>'Users', 'action'=>'notesview'));
foreach($allnotes as $viewnotes):
{
    echo $viewnotes['Note']['notes']; 
    echo "<br>";
    echo $viewnotes['Note']['created'];
    echo "<br>";
    echo $viewnotes['User']['name'];

}
endforeach;

Now in the element you can see ” echo $viewnotes[‘User’][‘name’]; “. I want Name field from User model to be retrieved in this element but i get the following error:

Notice (8): Undefined index: User [APP\View\Elements\notes.ctp, line 39]
  • 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-12T12:55:54+00:00Added an answer on June 12, 2026 at 12:55 pm

    Do you have the belongsTo relationship set inside your Note model?

    So, for example, you would have:

    <?php
    class Note extends AppModel {
        public $belongsTo = array('User');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model class like this: class Note(models.Model): author = models.ForeignKey(User, related_name='notes') content
Here's my use case : public class User extends Model {} public class TableA
I have my model for my users in MVC3: public class User { [Key]
I have a Django model: class Note(models.Model) : text = models.TextField() owner = models.ForeignKey(User)
I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other
I have a model that looks like this: class Invite(models.Model): user = models.ForeignKey(User) event
I have the following tables: class Note(model): note_data = models.ForeignKey(NoteData) important = models.BooleanField(default=0) deleted
I have the following models: class UserProfile(models.Model): user = models.OneToOneField(User) score = models.PositiveIntegerField() class
I have this model: class Event_Category(models.Model): event=models.ForeignKey(Event,related_name='event_category') category=models.ForeignKey(Category,related_name='events') user=models.ForeignKey(User) in the view: magazie_cats=Event_Category.objects.filter(event=instance).order_by('category').distinct() return
I have 2 tables, user & country NOTE: table name is singular ADOdb_Active_Record::TableKeyBelongsTo( 'user',

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.