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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:22:09+00:00 2026-06-05T03:22:09+00:00

I have run into a problem that defies all my attempts to unproblem it.

  • 0

I have run into a problem that defies all my attempts to unproblem it. Its probably simple, I have just totally exhausted myself on this one 🙂

Basically I want to give the user the ability to add modules (facebook id, a bio, text inputs) and assets (image logo, pdf, et al) to a page object.

I have set up a onetomany relationship for Module and Asset to Page.

Module works as expected, however Asset will not work at all: when PageController calls getAsset() from its entity, it is null. There is no error until I try to iterate over the Assets.

Also, in PageController there are the following namespace declarations:

use Linkme\SiteBundle\Entity\Module;
use Linkme\SiteBundle\Entity\Asset;

If I remove the Module declaration I get an error, but if I remove the Asset line, nothing changes. Therefore I believe the relationship is not created.

If I run

app/console doctrine:schema:create --dump-sql

then amongst others I get the following line:

ALTER TABLE Asset ADD CONSTRAINT FK_C36E75589D3B65E3 FOREIGN KEY (pageId) REFERENCES Page(id);

which makes me think the schema is correct. It as least understands Asset is related to Page

Im starting to feel I have a typo or I am totally missing something equally as obvious – any assistance on troubleshooting or other suggestions would be much appreciated!

app/console --version
Symfony version 2.0.1 - app/dev/debug

Page.php

/*
 * @ORM\OneToMany(targetEntity="Asset", mappedBy="pageId", cascade={"persist", "remove"})
 * @ORM\OrderBy({"type" = "ASC"})
 * @ORM\OrderBy({"id" = "ASC"})
 * 
 * @var ArrayCollection $assets
 */
protected $assets;

/**
 * @ORM\OneToMany(targetEntity="Module", mappedBy="pageId", cascade={"persist", "remove"})
 * @ORM\OrderBy({"type" = "ASC"})
 * @ORM\OrderBy({"id" = "ASC"})
 *
 * @var ArrayCollection $modules
 */
protected $modules;

/**
 * Set assets
 * @param Asset $assets
 */
public function setAssets(Asset $assets = null)
{
    $this->assets = $assets;
}

/**
 * Get assets
 *
 * @return Asset
 */
public function getAssets()
{
    echo '<br />Asset is '.gettype($this->assets); //   outut:  Asset is NULL
    return $this->assets;
}

/**
 * Set modules
 * @param Module $modules
 */
public function setModules(Module $modules = null)
{
    $this->modules = $modules;
}

/**
 * Get modules
 * @return Module
 */
public function getModules()
{
    echo '<br />Module is '.gettype($this->assets); //   output:  Module is object
    return $this->modules;
}

Asset.php

/**
 * @var integer $pageId
 *
 * @ORM\ManyToOne(targetEntity="Page", inversedBy="assets")
 * @ORM\JoinColumn(name="pageId", referencedColumnName="id")
 */
protected $pageId;

Module.php

/**
 * @var integer $pageId
 *
 * @ORM\ManyToOne(targetEntity="Page", inversedBy="modules")
 * @ORM\JoinColumn(name="pageId", referencedColumnName="id")
 */
protected $pageId;

PageController.php

use Linkme\SiteBundle\Entity\Module;
use Linkme\SiteBundle\Entity\Asset;

/**
 * Add modules  and assets to a page
 *
 * @Route("/{id}/wizardmodule", name="page_wizardmodule")
 * @Template()
 */
public function wizardmoduleAction($id)
{
    $em = $this->getDoctrine()->getEntityManager();
    $page = $em->getRepository('LinkmeSiteBundle:Page')->find($id);
    $modules = $page->getModules();
    $assets = $page->getAssets();        

depmod

[symfony]
    git=http://github.com/symfony/symfony.git
    version=v2.0.1

[twig]
    git=http://github.com/fabpot/Twig.git
    version=v1.1.2

[monolog]
    git=http://github.com/Seldaek/monolog.git
    version=1.0.1

[doctrine-common]
    git=http://github.com/doctrine/common.git
    version=2.1.1

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.1.1

[doctrine]
    git=http://github.com/doctrine/doctrine2.git
    version=2.1.1

[swiftmailer]
    git=http://github.com/swiftmailer/swiftmailer.git
    version=v4.1.1

[assetic]
    git=http://github.com/kriswallsmith/assetic.git
    version=v1.0.1

[twig-extensions]
    git=http://github.com/fabpot/Twig-extensions.git

[metadata]
    git=http://github.com/schmittjoh/metadata.git
    version=1.0.0

[SensioFrameworkExtraBundle]
    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
    version=v2.0.1

[JMSSecurityExtraBundle]
    git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
    target=/bundles/JMS/SecurityExtraBundle
    version=v2.0.1

[SensioDistributionBundle]
    git=http://github.com/sensio/SensioDistributionBundle.git
    target=/bundles/Sensio/Bundle/DistributionBundle
    version=v2.0.1

[SensioGeneratorBundle]
    git=http://github.com/sensio/SensioGeneratorBundle.git
    target=/bundles/Sensio/Bundle/GeneratorBundle
    version=v2.0.1

[AsseticBundle]
    git=http://github.com/symfony/AsseticBundle.git
    target=/bundles/Symfony/Bundle/AsseticBundle
    version=v1.0.0
  • 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-05T03:22:10+00:00Added an answer on June 5, 2026 at 3:22 am

    I got it! and as I predicted, it was an incredibly annoying PEBKAC….

    The relationship was not being created because the annotations were not being read, because I was missing a * on the annotations comment box….. ddddoooohhhhh!

    Page.php

    Before:

    /*      <==========================   there is only one * here. It needs to be two: **
     * @ORM\OneToMany(targetEntity="Asset", mappedBy="pageId", cascade={"persist", "remove"})
     * @ORM\OrderBy({"type" = "ASC"})
     * @ORM\OrderBy({"id" = "ASC"})
     *
     * @var ArrayCollection $assets
     */
    protected $assets;
    

    After:

    /**      <==========================   like this.
     * @ORM\OneToMany(targetEntity="Asset", mappedBy="pageId", cascade={"persist", "remove"})
     * @ORM\OrderBy({"type" = "ASC"})
     * @ORM\OrderBy({"id" = "ASC"})
     *
     * @var ArrayCollection $assets
     */
    protected $assets;
    

    I’d just like to say a big thanks to everyone who helped out with this problem.

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

Sidebar

Related Questions

I've just installed VS2008 and have run into a problem that I'm sure can
I have run into a problem that is a little irritating. Here is my
I frequently run into the problem that I have to preserve state between several
I've run into an rather irritating problem in java. I have a program that
Frequently I have run into a problem when installing gems that provides a problem
Hello StackOverflow community, I have run into a problem that quite frankly is baffling
I've run into a problem that I'm certain others have hit and solved. In
I'm pretty new to javascript and jquery, and have run into a problem that
I am a very inexperienced developer and have run into a problem that should
I have run into a problem while writing C++ code that needs to compile

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.