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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:46:22+00:00 2026-05-27T22:46:22+00:00

I have to create a multilingual table so i choose this schema: Article (

  • 0

I have to create a multilingual table so i choose this schema:

Article ( id, name_translation_fk)

Translation ( id )

Translation_Text (id, language, translation_fk, text)

Now i need to add names in different languages for an article that allready exists.
Doctrine gives me this error:


Catchable Fatal Error: Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given, called in */vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php on line 416 and defined in */vendor/doctrine-common/lib/Doctrine/Common/Collections/ArrayCollection.php line 46


I have no clue what the problem could be since all the entities are well declared.I think the issue is somewhere in the Form Class.

I have posted below my entities, forms and views implicated.

Article

 class Article
 {

  /**
   * @ORM\ManyToOne(targetEntity="Translation", inversedBy="article_name", cascade=  {"persist"})
   * @ORM\JoinColumn(name ="name", referencedColumnName="id")
   */
  protected $name;
 }

Translation

class Translation
{

    /**
     * @ORM\OneToMany(targetEntity="Translation_Text", mappedBy="translation", cascade={"persist"})
     */
     public $translation_text;

    /**
    * @ORM\OneToMany(targetEntity="Article", mappedBy="name", cascade={"persist"})
    */
    protected $article_name;      

    public function __construct()
    {
        $this->translation_text = new ArrayCollection();
        $this->article_name = new ArrayCollection();
    }
 }

Translation_Text

class Translation_Text
{

/**
 * @ORM\ManyToOne(targetEntity="Language", inversedBy="translation_text")
 * @ORM\JoinColumn(name ="language_id", referencedColumnName="id")
 */
protected $language;

/**
 * @ORM\ManyToOne(targetEntity="Translation", inversedBy="translation_text")
 * @ORM\JoinColumn(name ="translation_id", referencedColumnName="id")
 */
protected $translation;
 }

The form

class TranslationTextType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder->add('text','text');                    
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Udo\WebserviceBundle\Entity\Translation_Text',
        );
    }

    public function getName()
    {
        return 'translation_text';
    }

}

class TranslationType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {            
        $builder->add('translation_text',new TranslationTextType());
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Udo\WebserviceBundle\Entity\Translation',
        );
    }

    public function getName()
    {
        return 'translation';
    }

}

class ArticleTranslationForm extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder->add('name',new TranslationType());
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Udo\WebserviceBundle\Entity\Article',
        );
    }

    public function getName()
    {
        return 'article';
    }
}

The controller

 $article = $em->getRepository('Udo\WebserviceBundle\Entity\Article')->find($id);
 $form = $this->createForm(new ArticleTranslationForm(),$article);

The form view

<form action="{{path('article_translate', { 'id': entity.id }) }}" method="post" {{        form_enctype(form) }}>
{{form_row(form.name.translation_text.text)}}
{{form_rest(form)}}
<input type="submit" />
</form>
  • 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-27T22:46:23+00:00Added an answer on May 27, 2026 at 10:46 pm

    Since it is a ont-to-many relationship, you should use collection:

    $builder->add('translation_text', 'collection', array('type' => new TranslationTextType()));
    

    instead of:

    $builder->add('translation_text',new TranslationTextType());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are now using Django to develop a multilingual website. We have different language
I have create my own NSOpenGLView class, right now the data that i want
I have create name range on sheet A so I need to use this
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON
I've read this book section about git branches. I have create a branch called
i have create a customize feature in open atrium. now i have to implement
I have create a array containg person firstname,lastmane and number. Now i want to
I have create the list-activity.Now I want to add new view with with map
i have create a c# form application for parsing Html using Winista.html parser. Now
I have built a multilingual website with CodeIgniter using this library: http://codeigniter.com/wiki/URI_Language_Identifier/ I use

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.