adamwathan / bootforms

Rapid form generation with Bootstrap 3 and Laravel.
MIT License
417 stars 103 forks source link

Alter the checkbox HTML structure #107

Closed vpratfr closed 8 years ago

vpratfr commented 8 years ago

Hi,

I would like to have custom checkboxes, and that is made easy with flatlogic/awesome-bootstrap-checkbox

With that package though the markup needs to differ a bit from the standard Bootstrap markup.

I.e. instead of

  <div class="checkbox">
    <label>
      <input type="checkbox"> Check me out
    </label>
  </div>

You need to write

  <div class="checkbox">
    <input type="checkbox" id="checkbox1">
    <label for="checkbox1">
        Check me out
    </label>
  </div>

Which is the easiest way to have your package output that kind of HTML instead of the standard one?

Is there a way to extend the package maybe by replacing the checkbox class with my own?

ghost commented 8 years ago

+1. Maybe we can extend the library using the IOC container, but I will wait for the owner opinion about it.

jesseleite commented 8 years ago

There isn't a Bootstrap 4 implementation of Bootforms yet. That said, Bootstrap 4 still suggests we wrap the input with the label. If you want custom checkbox rendering, you can always extend the package in your app to setup custom checkbox rendering. We want to stick to native Bootstrap, as suggested by their documentation, as much as possible :)

vpratfr commented 8 years ago

Hi,

The library I mentionned above is not about Bootstrap 4, it works with BS 3 too. And I do not really want you to change your current implementation, that is fine to me.

What I wanted to know is precisely how to extend the package to change the way checkboxes are rendered.

I did not see any docs about it and even after searching a bit in the source code I did not see how I could register my own component.

adamwathan commented 8 years ago

You would have to extend this class (and maybe the horizontal one if you are using both) and just override whatever methods you need to to change the markup.

The package doesn't support registering different components or anything out of the box, you'll just need to override whatever methods you discover you need to, like a bunch of stuff around here:

https://github.com/adamwathan/bootforms/blob/master/src/AdamWathan/BootForms/BasicFormBuilder.php#L70-L99