What is the reason for the disparity in the way a form type is displayed?

Two versions of a small project exist, 'webpack' and 'retro'. The webpack version utilizes

../app.scss/...@import "~bootstrap/scss/bootstrap";
for serving styles (css), while the retro version uses the outdated
<link rel="stylesheet" href="{{ asset("css/bootstrap.min.css") }}"/>
method. Both projects have identical source code in directories ../src and ../template.

The issue arises with the differing rendering of a CheckboxType form field between the two versions. The timelines within Symfony's profiler show discrepancies. What could be causing this variation?

Note: The differences highlighted here are not unique to these specific projects, as distinct rendering variations occur across all forms.

Template snippet:

    <div class="col-6">
        {{ form_row(form.meal_type) }}
    </div>

Retro Version Example:

https://i.sstatic.net/Rgl38.jpg

Retro HTML:

<div>
    <div id="meal_meal_type">
        <input type="radio" id="meal_meal_type_0" name="meal[meal_type]" required="required" value="Breakfast" checked="checked" />
        <label for="meal_meal_type_0" class="required">Breakfast</label>
        <input type="radio" id="meal_meal_type_1" name="meal[meal_type]" required="required" value="Lunch" />
        <label for="meal_meal_type_1" class="required">Lunch</label>
        <input type="radio" id="meal_meal_type_2" name="meal[meal_type]" required="required" value="Dinner" />
        <label for="meal_meal_type_2" class="required">Dinner</label>
    </div>
</div>

Webpack Version Example:

https://i.sstatic.net/USYLx.jpg

Webpack HTML:

<fieldset class="mb-3">
    <div id="meal_meal_type">
        <div class="form-check">
            <input type="radio" id="meal_meal_type_0" name="meal[meal_type]" required="required" class="form-check-input" value="Breakfast" checked="checked" />
            <label class="form-check-label required" for="meal_meal_type_0">Breakfast</label>
        </div>
        <div class="form-check">
            <input type="radio" id="meal_meal_type_1" name="meal[meal_type]" required="required" class="form-check-input" value="Lunch" />
            <label class="form-check-label required" for="meal_meal_type_1">Lunch</label>
        </div>
        <div class="form-check">
            <input type="radio" id="meal_meal_type_2" name="meal[meal_type]" required="required" class="form-check-input" value="Dinner" />
            <label class="form-check-label required" for="meal_meal_type_2">Dinner</label>
        </div>
    </div>        
</fieldset>

A notable difference is also observed in the timelines associated with each respective method.

Retro Timeline:

https://i.sstatic.net/hBuGv.jpg

Webpack Timeline:

https://i.sstatic.net/xB3Mo.jpg

Answer №1

Your "old-school html" and "modern html with webpack" have different form themes that dictate how the form elements are displayed.

The former uses the default form_div_layout.html.twig, while the latter utilizes one of the bootstrap form themes.

You have the option to set the form themes globally in

[project dir]/config/packages/twig.yaml
or individually in the template itself (although global setting is generally recommended).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can a class be passed to the binding attribute in Angular framework?

We currently have a system in place that is dependent on a numeric value being set to either 1 or 2 in order to display specific icons. This method is functional. <span *ngIf="config.icon" [class.fas]="true" [class.fa-plus]="icon===1" ...

Header with a dropdown select option

In the process of developing a monitoring system, I am in need of a feature that allows users to select varying numbers of days. Here is the desired style: Previous [Dropdown Selection] Days https://i.sstatic.net/ysk6X.png Ideally, I do not want any bor ...

How to properly align an object in a specified ul, li list

I'm currently facing an issue while building a Joomla site. I have set a background image for my li elements, but the items within the li are not centered as expected. The website I am working on is www.outlawsofhealth.com. The specific list in quest ...

There is no class present in the @Apply layer with Tailwind styling

I've been searching for what seems like a simple solution, but I can't seem to find it. While researching similar issues, I noticed that people were having problems with the Hover style and extra white space after it, which is not the issue in my ...

Guide to creating scroll-based animations for a Div element

I've been brainstorming ways to rotate a div as I scroll. My goal is to recreate the effect shown in this codepen. However, I'm struggling to implement scrolling functionality. What I envision is scrolling down causing the word Data to rotate in ...

Adjustment of Facebook button positioning in floating bar on Firefox

My floating bar currently has 5 social buttons, but I've noticed that the Facebook button is shifting about 20 pixels to the left. Could this be an issue with the CSS elements? After inspecting the elements, I found that when I remove position: absol ...

Customize button appearance within mat-menu in Angular versions 2 and above

Is there a way to style my mat-menu to function similar to a modal dialog? I am having difficulty with the styling aspect and need advice on how to move the save and reset buttons to the right while creating space between them. I have attempted to apply st ...

Accordion menu with smooth CSS3 transitions

I created a unique accordion menu to replace the select form control, and I am interested in using CSS3 transitions to give it a smooth expand and contract effect. Feel free to check out my work on jsfiddle: http://jsfiddle.net/hKsCD/4/ In order to achi ...

Adding a background image in javascript using data from a MySQL database

My current tech stack includes CodeIgniter, vanilla JavaScript, AJAX, CSS, and MySQL. I am trying to figure out how to set the background of an image that is stored in a MySQL database. While the following code is error-free and working perfectly, my cha ...

What is the best way to utilize *ngFor for looping in Angular 6 in order to display three images simultaneously?

I have successfully added 3 images on a single slide. How can I implement *ngFor to dynamically load data? <carousel> <slide> <img src="../../assets/wts1.png" alt="first slide" style="display: inline-blo ...

When resizing, the image problem does not transition to the next column

Just started learning how to code and I've been stuck on this issue for a while now. Whenever I resize the browser window, the image doesn't move down to the next line after the .text class like I want it to. Instead, it overflows off the page to ...

A difference in the way content is displayed on Firefox compared to Chrome, Edge, and Safari

Recently, I encountered an issue with a tool I had developed for generating printable images for Cross-Stitch work. The tool was originally designed to work on Firefox but is now only functioning properly on that browser. The problem at hand is whether th ...

To grab a specific CSS attribute from a stylesheet using JavaScript

I am looking for a way to extract the value from a CSS file using a JavaScript function. Take a look at my code snippet below: HTML file -> <link rel="stylesheet" type="text/css" href="test_css.css" /> <script type="text/javascript ...

The Bootstrap Jumbotron section stubbornly stays above the footer

I'm currently working on a Bootstrap 3 page and facing an issue where the yellow area does not seamlessly transition into the green footer. Instead, there is a white space between the end of the yellow area and the start of the footer. How can I resol ...

Error: The requested module could not be located due to inability to resolve the JSON file

When I run npm run dev to execute my code, it shows multiple errors. The first error displayed is Module not found: Error: Can't resolve '../../build/contracts/User.json'. Despite having the necessary configurations in my webpack.config.js f ...

What is the best way to assign two styles with the same value in a single line of code?

Can you suggest a simpler method for expressing left:15%;right:15%, such as using left,right:15% or something equivalent? Your assistance is greatly appreciated! ...

The sequence of HTML attributes

Could there be a subjective angle to this question (or maybe not)... I work on crafting web designs and applications using Visual Studio and typically Bootstrap. When I drag and drop a CSS file into an HTML document, the code generated by Visual Studio loo ...

Tips for aligning images within Bootstrap columns and using auto zoom to properly fill the space

Here is the code snippet for displaying images: <div class="row"> <div class="col-12"> <div class="row"> <div class="col-lg-6 col-md-6 col-sm-12"> <div class=&qu ...

Icon-enhanced Bootstrap dropdown selection

I have a unique select dropdown using Bootstrap where I want to display icons like the example below: https://i.sstatic.net/dZmTS.png <!DOCTYPE html> <html> <head> <script src="/scripts/snippet-javascript-console.min.js?v=1"& ...

Error: Unable to locate 'regenerator-runtime' in Next.js 12.1.5 when using React 18 and Node 16

Here is the content of my package.json file: "scripts": { "dev": "next dev" }, "dependencies": { "next": "^12.1.5", "react": "^18.0.0", "react-dom&q ...