LoginSignup
0
0

More than 1 year has passed since last update.

Symfony FormBuilderでlabelを消したい

Posted at

Symfony初心者です。
twigを使っていますが、通常、twig上でphpの関数が使えず、viewでロジックを書かせないという強い意図を感じます。

さて、FormBuilderでlabelを消そうとして、調べても情報が見つかりませんでした。
古い情報も多いですね。

ソースの中を見てもわからなかったのですが、試行錯誤した結果、labelをfalseにするとラベルを消すことができました。

これに限らず、symfonyでよいドキュメントがあったらコメント欄で教えてください。
公式に載ってないこともあり、調べるのに時間がかかってしまいますね。

前提

Symfony 5.4

XxxxxxxxController.php
   #[Route('/xxxxx', name: 'xxxxx')]
    public function index(Request $request): Response
    {
         $form = $this->createFormBuilder()
             ->add('input', NumberType::class, [
                 'label' => false
             ])
             ->add('save', SubmitType::class, ['label' => 'submit'])
             ->getForm();

        return $this->render('xxxxxxxx/index.html.twig', [
            'form' => $form->createView(),
        ]);
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0