そのような質問がたくさんあることは知っていますが、それらを読んだ後でも問題を解決できませんでした。
実在物
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Orders
*
* @ORM\Table(name="orders")
* @ORM\Entity(repositoryClass="AppBundle\Repository\OrdersRepository")
*/
class Orders
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="shopOrderId", type="string", unique=true)
*/
private $shopOrderId;
/**
* @var string
*
* @ORM\Column(name="postBuyFormMsg", type="string")
*/
private $postBuyFormMsg;
/**
* @var boolean
*
* @ORM\Column(name="invoice", type="boolean")
*/
private $invoice;
/**
* @var string
*
* @ORM\Column(name="payType", type="string")
*/
private $payType;
/**
* @var string
*
* @ORM\Column(name="payStatus", type="string")
*/
private $payStatus;
/**
* @var integer
*
* @ORM\Column(name="shipmentType", type="integer")
*/
private $shipmentType;
/**
* @var datetime
*
* @ORM\Column(name="orderDate", type="datetime")
*/
private $orderDate;
// /**
// * @var integer
// *
// * @ORM\Column(name="status", type="integer")
// */
// private $status;
/**
* @var boolean
*
* @ORM\Column(name="verified", type="boolean")
*/
private $verified = 0;
/**
* @var boolean
*
* @ORM\Column(name="sent", type="boolean")
*/
private $sent = 0;
/**
* @var boolean
*
* @ORM\Column(name="canceled", type="boolean")
*/
private $canceled = 0;
/**
* @var string
*
* @ORM\Column(name="adminComment", type="string", nullable=true)
*/
private $adminComment;
/**
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="id")
* @ORM\JoinColumn(name="customerId", referencedColumnName="id")
*/
private $customerId;
/**
* @ORM\OneToMany(targetEntity="OrdersDetails", mappedBy="orderId")
*/
private $orderId;
/**
* @ORM\OneToMany(targetEntity="OrderData", mappedBy="orderData")
*/
private $orderData;
/**
* @ORM\OneToMany(targetEntity="OrderHistory", mappedBy="orderHistory")
*/
private $orderHistory;
/**
* @ORM\ManyToOne(targetEntity="Shops", inversedBy="id")
* @ORM\JoinColumn(name="shopId", referencedColumnName="id")
*/
private $shopId;
/**
* Constructor
*/
public function __construct()
{
$this->orderId = new \Doctrine\Common\Collections\ArrayCollection();
$this->orderData = new \Doctrine\Common\Collections\ArrayCollection();
$this->orderHistory = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set shopOrderId
*
* @param string $shopOrderId
*
* @return Orders
*/
public function setShopOrderId($shopOrderId)
{
$this->shopOrderId = $shopOrderId;
return $this;
}
/**
* Get shopOrderId
*
* @return string
*/
public function getShopOrderId()
{
return $this->shopOrderId;
}
/**
* Set postBuyFormMsg
*
* @param string $postBuyFormMsg
*
* @return Orders
*/
public function setPostBuyFormMsg($postBuyFormMsg)
{
$this->postBuyFormMsg = $postBuyFormMsg;
return $this;
}
/**
* Get postBuyFormMsg
*
* @return string
*/
public function getPostBuyFormMsg()
{
return $this->postBuyFormMsg;
}
/**
* Set invoice
*
* @param boolean $invoice
*
* @return Orders
*/
public function setInvoice($invoice)
{
$this->invoice = $invoice;
return $this;
}
/**
* Get invoice
*
* @return boolean
*/
public function getInvoice()
{
return $this->invoice;
}
/**
* Set payType
*
* @param string $payType
*
* @return Orders
*/
public function setPayType($payType)
{
$this->payType = $payType;
return $this;
}
/**
* Get payType
*
* @return string
*/
public function getPayType()
{
return $this->payType;
}
/**
* Set payStatus
*
* @param string $payStatus
*
* @return Orders
*/
public function setPayStatus($payStatus)
{
$this->payStatus = $payStatus;
return $this;
}
/**
* Get payStatus
*
* @return string
*/
public function getPayStatus()
{
return $this->payStatus;
}
/**
* Set shipmentType
*
* @param integer $shipmentType
*
* @return Orders
*/
public function setShipmentType($shipmentType)
{
$this->shipmentType = $shipmentType;
return $this;
}
/**
* Get shipmentType
*
* @return integer
*/
public function getShipmentType()
{
return $this->shipmentType;
}
/**
* Set orderDate
*
* @param \DateTime $orderDate
*
* @return Orders
*/
public function setOrderDate($orderDate)
{
$this->orderDate = $orderDate;
return $this;
}
/**
* Get orderDate
*
* @return \DateTime
*/
public function getOrderDate()
{
return $this->orderDate;
}
/**
* Set verified
*
* @param boolean $verified
*
* @return Orders
*/
public function setVerified($verified)
{
$this->verified = $verified;
return $this;
}
/**
* Get verified
*
* @return boolean
*/
public function getVerified()
{
return $this->verified;
}
/**
* Set sent
*
* @param boolean $sent
*
* @return Orders
*/
public function setSent($sent)
{
$this->sent = $sent;
return $this;
}
/**
* Get sent
*
* @return boolean
*/
public function getSent()
{
return $this->sent;
}
/**
* Set canceled
*
* @param boolean $canceled
*
* @return Orders
*/
public function setCanceled($canceled)
{
$this->canceled = $canceled;
return $this;
}
/**
* Get canceled
*
* @return boolean
*/
public function getCanceled()
{
return $this->canceled;
}
/**
* Set adminComment
*
* @param string $adminComment
*
* @return Orders
*/
public function setAdminComment($adminComment)
{
$this->adminComment = $adminComment;
return $this;
}
/**
* Get adminComment
*
* @return string
*/
public function getAdminComment()
{
return $this->adminComment;
}
/**
* Set customerId
*
* @param \AppBundle\Entity\Customer $customerId
*
* @return Orders
*/
public function setCustomerId(\AppBundle\Entity\Customer $customerId = null)
{
$this->customerId = $customerId;
return $this;
}
/**
* Get customerId
*
* @return \AppBundle\Entity\Customer
*/
public function getCustomerId()
{
return $this->customerId;
}
/**
* Add orderId
*
* @param \AppBundle\Entity\OrdersDetails $orderId
*
* @return Orders
*/
public function addOrderId(\AppBundle\Entity\OrdersDetails $orderId)
{
$this->orderId[] = $orderId;
return $this;
}
/**
* Remove orderId
*
* @param \AppBundle\Entity\OrdersDetails $orderId
*/
public function removeOrderId(\AppBundle\Entity\OrdersDetails $orderId)
{
$this->orderId->removeElement($orderId);
}
/**
* Get orderId
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getOrderId()
{
return $this->orderId;
}
/**
* Add orderDatum
*
* @param \AppBundle\Entity\OrderData $orderDatum
*
* @return Orders
*/
public function addOrderDatum(\AppBundle\Entity\OrderData $orderDatum)
{
$this->orderData[] = $orderDatum;
return $this;
}
/**
* Remove orderDatum
*
* @param \AppBundle\Entity\OrderData $orderDatum
*/
public function removeOrderDatum(\AppBundle\Entity\OrderData $orderDatum)
{
$this->orderData->removeElement($orderDatum);
}
/**
* Get orderData
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getOrderData()
{
return $this->orderData;
}
/**
* Add orderHistory
*
* @param \AppBundle\Entity\OrderHistory $orderHistory
*
* @return Orders
*/
public function addOrderHistory(\AppBundle\Entity\OrderHistory $orderHistory)
{
$this->orderHistory[] = $orderHistory;
return $this;
}
/**
* Remove orderHistory
*
* @param \AppBundle\Entity\OrderHistory $orderHistory
*/
public function removeOrderHistory(\AppBundle\Entity\OrderHistory $orderHistory)
{
$this->orderHistory->removeElement($orderHistory);
}
/**
* Get orderHistory
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getOrderHistory()
{
return $this->orderHistory;
}
/**
* Set shopId
*
* @param \AppBundle\Entity\Shops $shopId
*
* @return Orders
*/
public function setShopId(\AppBundle\Entity\Shops $shopId = null)
{
$this->shopId = $shopId;
return $this;
}
/**
* Get shopId
*
* @return \AppBundle\Entity\Shops
*/
public function getShopId()
{
return $this->shopId;
}
}
コントローラ
public function orderAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$order = $em->getRepository('AppBundle:Orders')->findOneBy(array('id' => $id));
$adminCommentForm = $this->createForm(adminCommentType::class, $order);
if ($adminCommentForm->isValid() && $adminCommentForm->isSubmitted()) {
$order->setAdminComment($adminCommentForm);
$em->persist($order);
$em->flush();
}
return $this->render(':Orders:order.html.twig',
array(
'adminCommentForm' => $adminCommentForm->createView(),
)
);
}
フォームタイプ
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class adminCommentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('adminComment',TextareaType::class,array('label'=>false))
->add('save', SubmitType::class, array('label' => 'Dodaj'));
}
public function configureOptions(OptionsResolver $resolver)
{
}
public function getName()
{
return 'app_bundleadmin_comment_type';
}
}
ここで説明されているエンティティに __toString 関数を追加しようとしましたsymfony2 Catchable Fatal Error: Object of class could not be convert to string but it does not work. __toString メソッドで複数の変数を返し、最終的に機能させる方法は?