PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

[FIXED] Symfony - FormType - set field display:none by default

 January 31, 2022     display, field, label, styles, symfony     No comments   

Issue

in my formType on Symfony I try to hide a default field.

So I did like this:

        ->add('amountReduction', NumberType::class, [
            "required" => false,
            "label" => "Montant de la réduction",
            "attr" => [
                "style" => "width: 200px; display: none;"
            ],
        ])

The problem is that the label is still visible. I would like to display: none; the whole field by default.

The goal is then that in the template, I can make a $(".field").show() which will display the label and the entire field

Thanks for your help


Solution

Use the row_attr option.

->add('amountReduction', NumberType::class, [
            "required" => false,
            "label" => "Montant de la réduction",
            "row_attr" => [
                "class" => "d-none"
            ],
        ])


Answered By - Frank B
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing