Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap_3_layout.html.twig with inline-form has no spacing #25831

Closed
flaushi opened this issue Jan 18, 2018 · 14 comments
Closed

bootstrap_3_layout.html.twig with inline-form has no spacing #25831

flaushi opened this issue Jan 18, 2018 · 14 comments

Comments

@flaushi
Copy link

flaushi commented Jan 18, 2018

Q A
Bug report? yes
Symfony version 3.4

Hi,
I am using the bootstrap_3_layout.html.twig and configure the following form:

$data = [
            'startDate' => new DateTime('2017-10-01'),
            'endDate' => new DateTime('2017-12-31'),
            'reportDate' => new DateTime()];        
        
        $builder = $this->createFormBuilder($data, ['attr' => ['class' => 'form-inline']]);
        $builder
            ->add('startDate', DateType::class, [
                'label' => 'Von: ', 
                'html5' => true, 
                'widget' => 'single_text'])
            ->add('endDate', DateType::class, [
                'label' => 'Bis: ', 
                'html5' => true, 
                'widget' => 'single_text'])
            ->add('reportDate', DateType::class, [
                'label' => 'Berichtsdatum: ', 
                'html5' => true, 
                'widget' => 'single_text'])
            ->add('save', SubmitType::class, array('label' => 'Aktualisieren', 'attr' => ['class'=> 'btn-success']));

as result, I see the following:
image
So, there is no space between the form elements.

The created html looks fine, however, I have read here that maybe a only a space/newline is missing?

This Fiddle shows my created html code. If you just click on "Tidy" the newlines are created and the spaces appear.

@Nyholm
Copy link
Member

Nyholm commented Mar 18, 2018

This sure is an interesting issue. I can confirm that this behavior is reproducible. However, reading the boostap docs: http://getbootstrap.com/docs/3.3/css/#forms, I see that inline forms are expected to have like this.

Ie, there is nothing we could do about it. You should remove "form-inline" and you will be better off. (maybe 😕 )

Here is an image from the docs:

screen shot 2018-03-18 at 16 01 20

I suggest closing this issue.

@flaushi
Copy link
Author

flaushi commented Mar 18, 2018

Well if the code to render the html form would just output a newline character after each form element, the problem would be solved.

@Nyholm
Copy link
Member

Nyholm commented Mar 18, 2018

Im not sure that is correct. HTML does not really care about new lines.

@flaushi
Copy link
Author

flaushi commented Mar 18, 2018

but the newline character would be interpreted like a space character. You have to understand that the browsers interpret the form fields like "one word" because there is absolutely no space between them. Try my fiddle, as soon as you give a space or newline, the form is displayed correctly.

@Nyholm
Copy link
Member

Nyholm commented Mar 18, 2018

I did try your fiddle. I did not see any difference from before and after clicking the "tidy" button.

@flaushi
Copy link
Author

flaushi commented Mar 18, 2018

which browser are you using? on my chrome, I see a difference if i just up a newline after each form-group-div:
image
https://jsfiddle.net/u12zhaqn/2/

@Nyholm
Copy link
Member

Nyholm commented Mar 19, 2018

Im on Firefox and Safari. Same results. Same in your fiddle and same on the bootstrap docs. I cannot see that whitespace matters.

@flaushi
Copy link
Author

flaushi commented Mar 19, 2018

Now I also tried with Safari, and I do see a difference. Please try these two fiddles:
https://jsfiddle.net/u12zhaqn/ (original code as generated by symfony)
https://jsfiddle.net/u12zhaqn/5/ (with a newline after each <div class="form-group">..</div>)

This is the original output (this time on Safari):
image

and this is the result with newlines (/5/):
image
And there is a difference obviously, right?

@xabbuh
Copy link
Member

xabbuh commented Nov 13, 2018

@flaushi Would you like to send a pull request?

@javiereguiluz
Copy link
Member

Maybe I missed something, but if we are talking about "inline forms", then the proposed change doesn't make sense to me. "Inline forms" display all fields in the same line (and in Bootstrap examples you'll see that most of the times they hide the labels).

The proposal here changes the default "inline form" design completely ... so I think it'd be better to not use "inline form" in this case and use normal forms and control the length of each field to display them in a single row.

@flaushi
Copy link
Author

flaushi commented Nov 20, 2018

I think you misunderstood the problem. I was not complaining about the label, I am missing the little margin between the text input fields.
If there is no space or newline in the HTML code, then the rendered result in a browser misses the little margin. I tried to change the template to create a PR, but did not find the position where the change must be done.

@xabbuh
Copy link
Member

xabbuh commented Apr 6, 2019

@flaushi Can you confirm that #30922 fixes this issue?

@fabpot fabpot closed this as completed Apr 6, 2019
fabpot added a commit that referenced this issue Apr 6, 2019
…orms (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[TwigBridge] fix horizontal spacing of inlined Bootstrap forms

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25831
| License       | MIT
| Doc PR        |

Commits
-------

7113a53 fix horizontal spacing of inlined Bootstrap forms
@flaushi
Copy link
Author

flaushi commented Apr 6, 2019

Perfect, thanks!!!

@xabbuh
Copy link
Member

xabbuh commented Apr 6, 2019

Thank you for the confirmation. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants