Code Monkey home page Code Monkey logo

laravel-html-bootstrap-4's People

Contributors

axyr avatar jamespoel avatar jyhsu2000 avatar marvinschroeder avatar micalm avatar peter279k avatar pm-consultancy avatar vpratfr avatar wvdongen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

laravel-html-bootstrap-4's Issues

Tests for forms

Would be good to write some tests for some advanced features of forms:

  • showing errors with fields
  • model binding
  • getting old value

Radio Group doesn't repopulate correctly

{{ bs()->formGroup()->label('Is 1=1?') ->control( bs()->radioGroup('smaller_sizes', [ 'Y' => 'Yes', 'N' => 'No' ]) ) }}

If the form errors, both radios are marked as 'checked'. Fixed in #41

Make CustomFile requireable

Is the CustomFile element "requireable" (required="required")?

This code sets the required="required" attribute on the control div and not on the input element:

{!! bs()->formGroup()->control(
   bs()->file('document', 'Please select..')->attributes(['required' => 'required'])
)->label('Document') !!}

Add CI service

As title, I think it's good to use GitHub Action to be the CI service.

I can do for that once the repository owner accepts that :).

Data bind

Will be cool to have an opportunity to bind model data to form, for update record.

Form with enctype

Hey! Maybe I do something wrong, but when I add 'files' => true to options array for form, nothing happens... I saw sources, no code for this option. Need to add it.

"bs::alert" Component Throws Error

bs::alert component does not work as intended, you can try the first simple example in the documentation.

Below is stack trace:

Undefined variable: class (View: /foo/bar/vendor/marvinlabs/laravel-html-bootstrap-4/resources/views/alert.blade.php) (View: /foo/bar/vendor/marvinlabs/laravel-html-bootstrap-4/resources/views/alert.blade.php) (View: /foo/bar/vendor/marvinlabs/laravel-html-bootstrap-4/resources/views/alert.blade.php)

Environment

  • Laravel 5.8
  • laravel-html-bootstrap-4 1.6

Can't set disabled() on radioGroup

Thanks for adding the radio and radioGroup elements!

In the RadioGroup __call method are some methods that will be forwarded to the Radio elements, butdisabled is not one of them:

['radio' => '', 'forgetRadio' => 'forget', 'addRadio' => 'add']

There is some magic in the __call method I did not understand, but it not seems a matter of adding disabled (and 'readonly') to the array.

Multi-Select support?

Could you add multi-select support to a future release?
I can ->attribute('multiple') on a select, but I can't pass an array as the values.
Thanks ๐Ÿ’ฏ

Unable to change checkbox input id

Hi, when using the checkBox() method, I'm unable to change the checkbox id and leave the name different, eg. input name = permissions, id of input: permission-1;

Here is the code I've tried

@forelse($permissionsChunk as $permission)
    {!! bs()->checkBox()->id("permission-{$permission->id}")
->name('permissions[]')->description($permission->description) !!}
@empty
@endforelse

But id stays the same as input name. I think the problem is in this line (219):

return $element
->nameIf($name, $name)
->idIf($name, field_name_to_id($name, 'wrapper'))
->description($description)
->checked($isChecked);

It should somehow accept overriden id if the method id is called on the returned element object

Can you look into it please? Or am I doing something wrong? Thanks.

Checkbox with array of options generates checkboxes with duplicate id

Checkboxes with the name representing an array of options generates checkboxes with the same id

Example from: https://github.com/marvinlabs/laravel-html-bootstrap-4/blob/master/docs/checkbox.md#checkboxes-with-name-representing-an-array-of-options

{{ bs()->checkbox('hobbies[]')->id('hobby_ski')->description('Skiing') }}
{{ bs()->checkbox('hobbies[]')->id('hobby_surf')->description('Surfing') }}
{{ bs()->checkbox('hobbies[]')->id('hobby_dive')->description('Diving') }}

Generated HTML:

<div class="custom-control custom-checkbox" id="hobby_ski">
    <input class="custom-control-input" type="checkbox" name="hobbies[]" value="1" id="hobbies">
    <label class="custom-control-label" for="hobbies">Skiing</label>
</div>
<div class="custom-control custom-checkbox" id="hobby_surf">
    <input class="custom-control-input" type="checkbox" name="hobbies[]" value="1" id="hobbies">
    <label class="custom-control-label" for="hobbies">Surfing</label>
</div>
<div class="custom-control custom-checkbox" id="hobby_dive">
    <input class="custom-control-input" type="checkbox" name="hobbies[]" value="1" id="hobbies">
    <label class="custom-control-label" for="hobbies">Diving</label>
</div>

All ids in of the three checkboxes are "hobbies". The id should be set on the control object, not on the wrapper.

Radio checked comparison too strict

->checked($this->getFieldValue($this->name, $this->selectedOption === $radio->getValue()))

This wont work :

$options = array [1,2,3];
$checked = "1";

Ofcourse $checked could be casted to int, but for this situation using === is way to strict and == should be used.

Textarea class not found.

When using bs()->textarea()

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Class 'Spatie\Html\Elements\TextArea' not found

Error on /vendor/marvinlabs/laravel-html-bootstrap-4/src/Bootstrap/Elements/TextArea.php:17

Spatie deinfe the class as Textarea, not cap on first A

Radio Group ID Bug

This one seems to have appeared recently (I'm using 1.6.4):

{{ bs()->radioGroup('agree_terms_1', [
                                      'y' => 'I am interested!',
                                      'n' => 'No, thanks.',
                                    ], 'y') }}

I can't select anything other than the first radio. Upon closer inspection each radio button has the same ID:

<div class="radio-group" id="agree_terms_1_radio_group">
<div class="custom-control custom-radio">
    <input class="custom-control-input" type="radio" checked="checked" name="agree_terms_1" value="y" id="agree_terms_1">
    <label class="custom-control-label" for="agree_terms_1">I am interested!</label>
</div>

<div class="custom-control custom-radio">
    <input class="custom-control-input" type="radio" name="agree_terms_1" value="n" id="agree_terms_1">
    <label class="custom-control-label" for="agree_terms_1">No, thanks.</label>
</div>
</div>

old() function does not work with arrays

Example:

{{ bs()->text('profile[first_name]', $user->first_name) }}

If you submit a form containing the above, and there is a validation error, the value previously inputted into the form is not loaded back into the field.

Caused by ln 31 of OldFormInputProvider.php.
return $this->request->old(field_name_to_id($key), $default);

field_name_to_id($key) translates to "profile_first_name", wheras it should be "profile.first_name".

Changing the line to simply return $this->request->old($key, $default);, solves the issue.

Shortcut method to make a row out of a form group

As an effort to simplify creation of horizontal forms (related to #12, #14)

For instance

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

could be

    {{ bs()->formGroup(bs()->text('first_name', 'John'))
            ->label('First name', false)
            ->asRow(['sm' => [2, 10]]) }}

or with offsets in some cases :

    {{ bs()->formGroup(bs()->submit('Submit', 'secondary')->child(fa()->icon('send')->addClass('ml-2')))
            ->wrapControlIn(bs()->div()->addClass('col-sm-10 offset-sm-2'))
            ->addClass('row')}}

would be

    {{ bs()->formGroup(bs()->submit('Submit', 'secondary')->child(fa()->icon('send')->addClass('ml-2')))
            ->asRow(['sm' => [2, 10]]) }}

Maybe an API would be better to simplify building row classes:

->asRow(['sm' => [2, 10]])

Could be something like

->asRow(bs()->formRow()->sm(2, 10)->md(3, 10))
->asRow(bs()->formRow()
    ->sm(false, 10)) // false means that we should ignore column and offset the next one

Argument 1 passed to Radio::description() must be of the type string

bs()->radio('test')

gives the error:

Type error: Argument 1 passed to MarvinLabs\Html\Bootstrap\Elements\Radio::description() must be of the type string, null given

the MarvinLabs\Html\Bootstrap\Traits\BuildsForms::radio() method allows null values:

public function radio($name = null, $description = null, $isChecked = false)

but the Radio method description(string $text) does not allow null.

Model relations binding

Hey! How to bind model with relations? Like... I have post and have seo info for it. So, when I bind model, it works ok, but inputs with relations always null...
And validation errors don't show on relation inputs.

Labels can not contain html

When adding an 'accept terms' checkbox you can not add a link to a Terms & Conditions page/doc

 {{ bs()->formGroup(bs()->checkBox('accept_terms', 'I agree with the <a href="/terms" target="_blank">Terms & Conditions</a>'), '') }}

MarvinLabs\Html\Bootstrap\Elements\CheckBox::label() uses:

 ->text($element->description)

This probably can be replaced with : ?

 ->html($element->description)

No error message under field after failed validation

Hi, first of all, thanks for this awesom package, it is just what i was looking for.

However, I'm having a slight issue regarding validation and showing error messages. Right now, if validation fails, the fields get correct is-invalid class but i cannot see the error message from the validator (e.g. Field :field is required).

Here is my code:

<div class="row mb-3">
    <div class="col-6">
        {!! bs()->text('first_name')->placeholder(__('core::register.form.first_name')) !!}
    </div>
    <div class="col-6">
        {!! bs()->text('last_name')->placeholder(__('core::register.form.last_name')) !!}
    </div>
</div>
{!! bs()->inputGroup()->addClass('mb-3')->prefix("<span class='input-group-text'><i class='icon-user'></i></span>", false)->control(bs()->email('email')->placeholder(__('core::register.form.email'))) !!}
{!! bs()->inputGroup()->addClass('mb-3')->prefix('<span class="input-group-text"><i class="icon-lock"></i></span>', false)->control(bs()->password('password')->placeholder(__('core::register.form.password'))) !!}
 {!! bs()->inputGroup()->addClass('mb-3')->prefix('<span class="input-group-text"><i class="icon-lock"></i></span>', false)->control(bs()->password('password_confirmation')->placeholder(__('core::register.form.password_confirmation'))) !!}

And here is a screenshot after failed validation:
screenshot-2018-3-13 coreui - open source bootstrap admin template

Do i need to do something more for the error messages to show up?

Thanks

Policy to set some default properties on form children

For instance, it would be handy to specify which default classes should be applied to form groups, or maybe too which wrapper around the form control gets applied.

Would help reducing the code to build forms by a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.