473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Symfony, property is not recognised, "Notice: Undefined property:..."

103 100+
I am following Udemy course:
https://www.udemy.com/introduction-to-web-development-with-symfony2/#/lecture/933836

There is Post model with several fields: title, author, body;
which inherits from Timestampable model with field: createdAt.

When i try to display Post model in template, the Author and post are displayed, but field "createdAt" is not recognised and gives error "Notice: Undefined property: Blog\ModelBundle\Entity\Post::$createdAt".
(I comment out "createdAt" in template and than Author, title and post are displayed. )


_post.html.twig:
Expand|Select|Wrap|Line Numbers
  1. <article>
  2.  
  3.     <header><h2><a href="a">{{post.title}}</a></h2>     </header>
  4.  
  5.     <p>{{'post.on' | trans }} 
  6.         <time datetime="{{ post.createdAt | date('c') }}">{{ post.createdAt | date }} </time> 
  7.         {{ 'by' | trans }} <a href="a"> {{ post.author.name }} </a>
  8.     </p>
  9. </header>
  10.  
  11. <p> {{post.body |truncate(400)}} — <a href=""a">{{ 'read.more' | trans }} &raquo;</a></p>
  12. </article>
C:\Bitnami\wampstack-5.4.38-0\sym_prog\myproject\src\Blog\ModelBundle\Entity\P ost.php
Expand|Select|Wrap|Line Numbers
  1. ...
  2. class Post extends Timestampable
  3. {
  4.     /**
  5.      * @var integer
  6.      *
  7.      * @ORM\Column(name="id", type="integer")
  8.      * @ORM\Id
  9.      * @ORM\GeneratedValue(strategy="AUTO")
  10.      */
  11.     private $id;
  12.  
  13.     /**
  14.      * @var string
  15.      *
  16.      * @ORM\Column(name="title", type="string", length=150)
  17.      * @Assert\NotBlank
  18.      */
  19.     private $title;
  20.  
  21.     /**
  22.      * @var string
  23.      *
  24.      * @ORM\Column(name="body", type="text")
  25.      * @Assert\NotBlank
  26.      */
  27.     private $body;
  28.  
  29.     /**
  30.      * @var Author
  31.      *
  32.      * @ORM\ManyToOne(targetEntity="Author", inversedBy="posts")
  33.      * @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=false)
  34.      * @Assert\NotBlank
  35.      */
  36.     private $author;
  37. ...

C:\Bitnami\wampstack-5.4.38-0\sym_prog\myproject\src\Blog\ModelBundle\Entity\T imestampable.php

Expand|Select|Wrap|Line Numbers
  1. .... abstract class Timestampable
  2. {
  3.  
  4.     /**
  5.      *
  6.      * @var \DateTime
  7.      * @ORM\Column (name="created_at", type="datetime")
  8.      */
  9.     private $createdAt;
  10.      /**
  11.      * Construct
  12.      */
  13.     public function __construct()
  14.     {
  15.         $this->createdAt = new \DateTime();
  16.     }....
Mar 22 '15 #1
0 1257

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Job Lot | last post by:
How can I implement a Custom Property similar to Location property, where user can either provide values to Location (10,10) or drill down to individual coordinated X and Y. Thanks
1
by: JKop | last post by:
Would you classify the following code as "Undefined Behaviour" or as "Non- portable"? signed main() { signed char chedder = 130; } Relevant information:
23
by: Ken Turkowski | last post by:
The construct (void*)(((long)ptr + 3) & ~3) worked well until now to enforce alignment of the pointer to long boundaries. However, now VC++ warns about it, undoubtedly to help things work on 64...
14
by: Codemonkey | last post by:
Just a silly question, but why can't you overload a writeonly property with a readonly one? Surely the compiler can tell the difference of which one to call at compile time, depending on if it is...
0
by: Marty Meyers | last post by:
TIA for your help! Using PHP 4.3.9 doing some code cleanup on an existing site. I have reduced the problem to: This File is marty.php: <? class Refs { function scriptDir() { echo "Refs are...
3
by: Kenneth Kahl | last post by:
Hello, I would like to call a C++ programm out of Java with help of JNI. By the followed command I created a "shared library": g++ -shared -o libcalculate.so rechner.cpp When I create an...
0
by: Joe | last post by:
Hi I am trying to allow my property grid have a property with the values are dynamically generated at runtime I can create a static list but not dynamic Anyone have a suggestion or code...
3
by: s.z.s | last post by:
Hi! I hope the solution to that is not too stupid... I've got three files: <snip test_main.cc> #include"test.hh" int main(void) { A<inta1; a1.saywhat();
5
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : ...
0
by: Kurt Pindroh | last post by:
Connected to ibm DB2 database the following php code: $stmt = $dbh->query('select trim(FPDESC) as FPDESC from mylib.myfile'); $obj = $stmt->fetch(PDO::FETCH_OBJ); var_dump($obj); echo '<br>';...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.