Я работал над проектом Symfony в прошлом месяце, я мог бы разобраться с моими сущностями.
Но теперь я не могу вставить, обновить или удалять данные. Все хорошо, чтобы прочитать его. < /p>
Когда я отправляю форму, ошибка не отображается. отправить форму для создания идеи. Нет идеи создан. Но когда я попытался вернуть данные json, когда я отправляю свою форму, дата хороша, но никаких изменений в моей базе данных. < /P>
Я не знаю, с тех пор Есть эта проблема, все эти формы работали несколько недель назад. < /p>
Кто -нибудь знает, почему? маршрут: < /p>
/**
* @Route("/{projet}/{id_projet}/idee/nouvelle",name="projet_idee_nouvelle")
*/
public function projet_idee_nouvelle(int $id_projet,Request $request, ObjectManager $manager){
$idee=new Idee();
$repository = $this
->getDoctrine()
->getManager()
->getRepository('App:Projet')
;
$projet=$repository->find($id_projet);
$projets=array();
array_push($projets,$projet);
$form=$this->createForm(IdeeType::class,$idee, array(
'projets'=>$projets
));
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()){
$manager->persist($idee);
$manager->flush();
//redirection on the created project
return $this->redirectToRoute('projet_detail',array('id'=>$projet->getId()));
}
return $this->render('idee/idee_nouveau.html.twig',[
'form'=>$form->createView()
]);
}
< /code>
my "projet" объект: < /p>
/**
* @ORM\Entity(repositoryClass="App\Repository\ProjetRepository")
*/
class Projet
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=50)
* @Assert\NotBlank
*/
private $nom;
//{...} Other class attributes
/**
* @ORM\OneToMany(targetEntity="App\Entity\Idee", mappedBy="projet", cascade={"all"}, orphanRemoval=true)
*/
private $projetIdee;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Tache", mappedBy="projet", cascade={"all"}, orphanRemoval=true)
*/
private $projetTache;
}
< /code>
my idee entity: < /p>
/**
* @ORM\Entity(repositoryClass="App\Repository\IdeeRepository")
*/
class Idee
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Projet")
* @ORM\JoinColumn(nullable=false)
*/
private $projet;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank
*/
private $label;
/**
* @ORM\Column(type="text")
* @Assert\NotBlank
*/
private $texte;
}
< /code>
my twig, чтобы добавить идею: < /p>
{% extends 'base.html.twig' %}
{% block title %}Ajouter une idée{% endblock %}
{% block main %}
Ajouter une idée au projet
{{ form_start(form) }}
{{ form_row(form.projet, {'label':'Projet associé'})}}
{{ form_row(form.label, {'label':'Label de l\'idée','attr':{'placeholder':'Label de l\'idée'}}) }}
{{ form_row(form.texte, {'label':'Description','attr':{'placeholder':'Description'}}) }}
Ajouter l'idée
{{ form_end(form) }}
{% endblock %}
< /code>
my ideetype: < /p>
Подробнее здесь: https://stackoverflow.com/questions/596 ... ate-delete
Symfony Dectrine не выполняет вставку / обновление / удаление ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Symfony 6 / Dectrine - в драйвере произошло исключение: не удалось найти драйвера
Anonymous » » в форуме Php - 0 Ответы
- 42 Просмотры
-
Последнее сообщение Anonymous
-