marvinlabs / laravel-html-bootstrap-4

Bootstrap 4 fluent HTML builder
MIT License
42 stars 15 forks source link

Horizontal Form #12

Closed jyhsu2000 closed 6 years ago

jyhsu2000 commented 6 years ago

I would like to know if it support Horizontal Form or not. Does it? Or will it?

vpratfr commented 6 years ago

Hi,

According to that documentation, horizontal forms are just standard forms with some markup for the grid.

You can already implement these horizontal forms with the library.

What exactly would you need on top of the current features?

vpratfr commented 6 years ago

I think I got what you meant. I have added some functions to form groups to allow easy creation of horizontal rows. Open a new issue if needed. Closing this one for now.

jyhsu2000 commented 6 years ago

What I hope is that there will be a function openHorizontalForm() like openForm(), but it's for horizontal form. We can use this function to create a horizontal form easily, instead of adding class in each div, label and input manually.

There is a similar example from BootForms #horizontal-forms

vpratfr commented 6 years ago

Yes but that was Bootstrap 3, which had a different approach to horizontal forms.

I guess with a more general feature we could however address this issue (and a few others at the same time) in a clean and reusable way. See #14.

vpratfr commented 6 years ago

Will try to get that in 0.5.0. If you have a PR or suggestion, feel free to submit ;)

vpratfr commented 6 years ago

Can you give some ideas on #14 or #15? How does that look to you?

vpratfr commented 6 years ago

With #15 it becomes much simpler. Here is some sample code to automatically produce a row:

BEFORE

    {{-- Manually create a row --}}
    {{ bs()->formGroup(bs()->text('first_name', 'John'))
            ->wrapControlIn(bs()->div()->addClass('col-sm-10'))
            ->label('First name', false, ['col-sm-2'])
            ->addClass('row')}}

AFTER

    {{-- Create a row using the default configuration entry: config('bs4.form_rows.default') --}}
    {{ bs()->formGroup(bs()->inputGroup(bs()->text('username', 'johndoe'), '@'))
            ->label('Username', false)
            ->showAsRow() }}

    {{-- Create a row using a custom configuration entry: config('bs4.form_rows.no_label') --}}
    {{ bs()->formGroup(bs()->checkBox('remember', 'Remember me'))
            ->label('Remember me', true)
            ->showAsRow('no_label')}}

    {{ bs()->formGroup(bs()->submit('Submit', 'secondary')->child(fa()->icon('send')->addClass('ml-2')))
            ->showAsRow('centered')}}
jyhsu2000 commented 6 years ago

Awesome. I think showAsRow() is good enough. Thank you for updating so quickly.

vpratfr commented 6 years ago

No worries. I need it for a client so I am looking for ease of use too.