0

私はsymfony2で作業しており、2つのフォーム(グループ内の人)を埋め込んだときに問題が発生しました:

プロパティ "PersonEntity" も、メソッド "getPersonEntity()"、"isPersonEntity()"、"hasPersonEntity()"、"_ get()"、または " _call()" のいずれも存在せず、クラス "S118" にパブリック アクセスがありません。 \ebrahimiBundle\Entity\GroupEntity".

私の人物エンティティ:

<?php
namespace S118\ebrahimiBundle\Entity;
use Doctrine\ORM\Mapping AS ORM;

/** 
 * @ORM\Entity
 */
class PersonEntity
{
    /** 
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /** 
     * @ORM\Column(type="string", length=100, nullable=false)
     */
    private $f_name;

    /** 
     * @ORM\Column(type="string", length=100, nullable=false)
     */
    private $l_name;

    /** 
     * @ORM\Column(type="string", length=100, nullable=true)
     */
    private $tell;

    /** 
     * @ORM\Column(type="string", length=100, nullable=true)
     */
    private $fileName;

    /** 
     * @ORM\OneToMany(targetEntity="S118\ebrahimiBundle\Entity\BuyEntity", mappedBy="PersonEntity")
     */
    private $BuyEntities;

    /** 
     * @ORM\OneToMany(targetEntity="S118\ebrahimiBundle\Entity\UsageEntity", mappedBy="PersonEntity")
     */
    private $UsageEntities;

    /** 
     * @ORM\ManyToOne(targetEntity="S118\ebrahimiBundle\Entity\GroupEntity", inversedBy="PersonEntities")
     * @ORM\JoinColumn(name="Gid", referencedColumnName="id", nullable=false)
     */
    private $GroupEntity;
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->BuyEntities = new \Doctrine\Common\Collections\ArrayCollection();
        $this->UsageEntities = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set f_name
     *
     * @param string $fName
     * @return PersonEntity
     */
    public function setFName($fName)
    {
        $this->f_name = $fName;

        return $this;
    }

    /**
     * Get f_name
     *
     * @return string 
     */
    public function getFName()
    {
        return $this->f_name;
    }

    /**
     * Set l_name
     *
     * @param string $lName
     * @return PersonEntity
     */
    public function setLName($lName)
    {
        $this->l_name = $lName;

        return $this;
    }

    /**
     * Get l_name
     *
     * @return string 
     */
    public function getLName()
    {
        return $this->l_name;
    }

    /**
     * Set tell
     *
     * @param string $tell
     * @return PersonEntity
     */
    public function setTell($tell)
    {
        $this->tell = $tell;

        return $this;
    }

    /**
     * Get tell
     *
     * @return string 
     */
    public function getTell()
    {
        return $this->tell;
    }

    /**
     * Set fileName
     *
     * @param string $fileName
     * @return PersonEntity
     */
    public function setFileName($fileName)
    {
        $this->fileName = $fileName;

        return $this;
    }

    /**
     * Get fileName
     *
     * @return string 
     */
    public function getFileName()
    {
        return $this->fileName;
    }

    /**
     * Add BuyEntities
     *
     * @param \S118\ebrahimiBundle\Entity\BuyEntity $buyEntities
     * @return PersonEntity
     */
    public function addBuyEntitie(\S118\ebrahimiBundle\Entity\BuyEntity $buyEntities)
    {
        $this->BuyEntities[] = $buyEntities;

        return $this;
    }

    /**
     * Remove BuyEntities
     *
     * @param \S118\ebrahimiBundle\Entity\BuyEntity $buyEntities
     */
    public function removeBuyEntitie(\S118\ebrahimiBundle\Entity\BuyEntity $buyEntities)
    {
        $this->BuyEntities->removeElement($buyEntities);
    }

    /**
     * Get BuyEntities
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getBuyEntities()
    {
        return $this->BuyEntities;
    }

    /**
     * Add UsageEntities
     *
     * @param \S118\ebrahimiBundle\Entity\UsageEntity $usageEntities
     * @return PersonEntity
     */
    public function addUsageEntitie(\S118\ebrahimiBundle\Entity\UsageEntity $usageEntities)
    {
        $this->UsageEntities[] = $usageEntities;

        return $this;
    }

    /**
     * Remove UsageEntities
     *
     * @param \S118\ebrahimiBundle\Entity\UsageEntity $usageEntities
     */
    public function removeUsageEntitie(\S118\ebrahimiBundle\Entity\UsageEntity $usageEntities)
    {
        $this->UsageEntities->removeElement($usageEntities);
    }

    /**
     * Get UsageEntities
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getUsageEntities()
    {
        return $this->UsageEntities;
    }

    /**
     * Set GroupEntity
     *
     * @param \S118\ebrahimiBundle\Entity\GroupEntity $groupEntity
     * @return PersonEntity
     */
    public function setGroupEntity(\S118\ebrahimiBundle\Entity\GroupEntity $groupEntity)
    {
        $this->GroupEntity = $groupEntity;

        return $this;
    }

    /**
     * Get GroupEntity
     *
     * @return \S118\ebrahimiBundle\Entity\GroupEntity 
     */
    public function getGroupEntity()
    {
        return $this->GroupEntity;
    }
    public function  __toString()
    {
        return $this->f_name.' '.$this->l_name;

    }
}

そして私のグループエンティティ:

<?php
namespace S118\ebrahimiBundle\Entity;
use Doctrine\ORM\Mapping AS ORM;

/** 
 * @ORM\Entity
 */
class GroupEntity
{
    /** 
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /** 
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $name;

    /** 
     * @ORM\OneToMany(targetEntity="S118\ebrahimiBundle\Entity\BuyEntity", mappedBy="GroupEntity")
     */
    private $BuyEntities;

    /** 
     * @ORM\OneToMany(targetEntity="S118\ebrahimiBundle\Entity\PersonEntity", mappedBy="GroupEntity")
     */
    private $PersonEntities;
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->BuyEntities = new \Doctrine\Common\Collections\ArrayCollection();
        $this->PersonEntities = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return GroupEntity
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Add BuyEntities
     *
     * @param \S118\ebrahimiBundle\Entity\BuyEntity $buyEntities
     * @return GroupEntity
     */
    public function addBuyEntitie(\S118\ebrahimiBundle\Entity\BuyEntity $buyEntities)
    {
        $this->BuyEntities[] = $buyEntities;

        return $this;
    }

    /**
     * Remove BuyEntities
     *
     * @param \S118\ebrahimiBundle\Entity\BuyEntity $buyEntities
     */
    public function removeBuyEntitie(\S118\ebrahimiBundle\Entity\BuyEntity $buyEntities)
    {
        $this->BuyEntities->removeElement($buyEntities);
    }

    /**
     * Get BuyEntities
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getBuyEntities()
    {
        return $this->BuyEntities;
    }

    /**
     * Add PersonEntities
     *
     * @param \S118\ebrahimiBundle\Entity\PersonEntity $personEntities
     * @return GroupEntity
     */
    public function addPersonEntitie(\S118\ebrahimiBundle\Entity\PersonEntity $personEntities)
    {
        $this->PersonEntities[] = $personEntities;

        return $this;
    }

    /**
     * Remove PersonEntities
     *
     * @param \S118\ebrahimiBundle\Entity\PersonEntity $personEntities
     */
    public function removePersonEntitie(\S118\ebrahimiBundle\Entity\PersonEntity $personEntities)
    {
        $this->PersonEntities->removeElement($personEntities);
    }

    /**
     * Get PersonEntities
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getPersonEntities()
    {
        return $this->PersonEntities;
    }
    public function  __toString()
    {
        return $this->name;

    }
}

と私のグループビュー:

{% extends '::base.html.twig' %}

{% block body -%}
    <h1>GroupEntity creation</h1>

    {{ form(form) }}

        <ul class="record_actions">
    <li>
        <a href="{{ path('group') }}">
            Back to the list
        </a>
    </li>
</ul>
{% endblock %}

そして私の人型:

<?php

namespace S118\ebrahimiBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class PersonEntityType extends AbstractType
{
        /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('f_name')
            ->add('l_name')
            ->add('tell')
            ->add('fileName')
            ->add('GroupEntity')
        ;
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'S118\ebrahimiBundle\Entity\PersonEntity'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 's118_ebrahimibundle_personentity';
    }
}

そして私のグループフォーム:

<?php

namespace S118\ebrahimiBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class GroupEntityType extends AbstractType
{
        /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('PersonEntity','collection', array('type' => new PersonEntityType()))
        ;
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'S118\ebrahimiBundle\Entity\GroupEntity'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 's118_ebrahimibundle_groupentity';
    }
}

どうして???

4

1 に答える 1