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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:11:29+00:00 2026-06-15T17:11:29+00:00

I hava a entity with the following flied: /** * @ORM\ManyToOne(targetEntity=Document, inversedBy=posts) * @ORM\JoinColumn(name=document_id,

  • 0

I hava a entity with the following flied:

/**
 * @ORM\ManyToOne(targetEntity="Document", inversedBy="posts")
 * @ORM\JoinColumn(name="document_id", referencedColumnName="id")
 */
protected $image;

which I get with the following method:

public function indexAction() {
    $posts = $this->getDoctrine()
            ->getRepository('airpaprcms2Bundle:Post')
            ->findByPageType(1);

    if (!$posts) {
        throw $this->createNotFoundException('No posts in Database!');
    }

    return $this->render('airpaprcms2Bundle:Default:index.html.twig', array('posts' => $posts));
}

How can I access a property of the mapped object form within twig? I tried post.image.file (the mapped entity Document has a property file)

{% for post in posts %}
<div>
    <h1>
        <a href="{{ path('_view', {'slug': post.slug}) }}">{{ post.title }}</a>
    </h1>
    <p>{{ post.text }}</p>
    <img src="{{ post.image.name }}" alt="{{ post.title }}" />
</div>
{% endfor %}

and get the following error message:

Item "file" for "" does not exist in airpaprcms2Bundle:Default:index.html.twig at line 11

What is the right syntax to access the mapped document property?

  • 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-15T17:11:30+00:00Added an answer on June 15, 2026 at 5:11 pm

    You can access the property of your linked entity with the following twig syntax:

    {% for post in posts %}
    {{ post.entityName.propertyName }}
    {% endfor %}
    

    In your case that would be:

    {% for post in posts %}
    {{ post.image.propertyName }}
    {% endfor %}
    

    Be sure to check that all post entities are linked to an image object. If one post entity has no link to an image, you will get a property not found error when trying to render your page.

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

Sidebar

Related Questions

I hava following sql query SELECT animal_code, ISNULL(SUM(calve_milk + morning + evening), 0) /
I hava the sql as below: select a.dept, a.name from students a group by
My issue is quite simple, I hava a generic parent class with the following
i hava a set of following tables customer(cus_id,cus_name); jointAccount(cus_id,acc_number,relationship); account(acc_number,cus_id) now i want to
I hava a listview like the following. The text in the TextView comes from
I hava the next task in my ant file: <target name=initdb> <sql driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/dtest
I hava a Java mulithreading question. I have the following worker class: public class
I hava a Bitmap variable named bmp in Activity1 , and I want to
I hava an activity which might have to load data when it's starting up.
I hava a class called DBhelper, and now I created a new class called

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.