vendredi 26 février 2016

Symfony2, Twig and Checkboxes custom twig template

I am using bootstrap 3 for my template and I am aware of the templating that exist within the Symfony Twig Bridge. Below is what I would like to have in the end.

enter image description here

Where I have a grey area is where I would like to have my label at 90% alignment.

Below is what I currently have:

<div class="form-group">
  <div id="campaign_channel" class="col-xs-6">
    <input id="campaign_channel_1" type="checkbox" value="1" name="campaign[channel][]">
    <label for="campaign_channel_1">Facebook</label>
    <input id="campaign_channel_2" type="checkbox" value="2" name="campaign[channel][]">
    <label for="campaign_channel_2">Twiiter</label>
    <input id="campaign_channel_3" type="checkbox" value="3" name="campaign[channel][]">
    <label for="campaign_channel_3">LinkedIn</label>
    <input id="campaign_channel_4" type="checkbox" value="4" name="campaign[channel][]">
    <label for="campaign_channel_4">Instagram</label>
    <input id="campaign_channel_5" type="checkbox" value="5" name="campaign[channel][]">
    <label for="campaign_channel_5">Youtube</label>
   </div>
  </div>

Below is what I would like to have:

<div class="form-group">
  <div id="campaign_channel" class="checkbox col-xs-6">
     <div class="checkbox-label">Channel(s)</div>
     <div class="checkbox-clmn-1">
     </div>
     <div class="checkbox-clmn-2">
     </div>
  </div>
</div>

If, as shown in the example, we have 5 checkboxes I want to split any number of checkboxes by using the multiples of three. Say have the first three checkboxes in the first column in a case where total number is odd and then if even then checkboxes should be spraed equally in both checkbox columns.

Where exactly can I create this custom template "fields.html.twig" in my Symfony application so that I can actually play around with this idea?




Aucun commentaire:

Enregistrer un commentaire