私は createFormBuilder で作成されたフォームを表示して送信するために単一のアクションを使用しています
public function fooBar(){
// ... creating form and stuff
// on first Request i want to use the FlashBag to hold a "Fill out !" message
// how to if here ? if(first request){
$this->get('session')->getFlashBag()->add('notice', "Fill out!");
// }
if ($form->isValid()) {
$fooService->create($bar);
$this->get('session')->getFlashBag()->clear('notice');
$this->get('session')->getFlashBag()->add('notice', "Succesfully Submitted !");
} else {
$this->get('session')->getFlashBag()->add('notice', "Form is Invalid!");
}
// otherwise i see "Fill Out!" and "Form is Invalid" on the First request when i did not fill out anything yet
}
私の問題が理解できることを願っています、
基本的に、フォームが送信されなかった場合は isValid() が false と評価され、送信されたフォームに無効なプロパティが含まれていた場合は false と評価されます。
フォームが最初に表示されたときに特定のflasmessageを表示したい