1
我最近新建了Symfony(2.8),我试图在从表单提交图像文件后,用第二个实体的主要颜色填充第二个实体图片。在Symfony2中提交表单后填充第二个实体
现在,我就是这样从控制器做了一个试验:
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($image);
$extractor->setImage($image->getFile());
$palette = $extractor->extractPalette();
foreach($palette as $color => $weight){
$imageColor = new Color();
$imageColor->setImage($image);
$imageColor->setRgb($color);
$imageColor->setWeight($weight);
$em->persist($imageColor);
}
$em->flush();
它的工作,但我不认为,颜色应该是在形式或控制器也不是像实体。 那么,我应该如何处理颜色?
谢谢@Terenoth。 - 这么晚才回复很抱歉。 – Frankfurt