We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

wrap <label></label> around checkbox in volt

Hi @all,

how can i do this output in volt?

            <div class="checkbox">
                <label>
                    <input type="checkbox"> Checkbox
                </label>
            </div>

This is my code:

    <div class="checkbox">
            {{ form.render('region', ['class': 'col-xs-4']) }}  {{ form.label('region', ['class': 'col-xs-2']) }}
    </div>

Thank you :-)

Rgds

Stefan

Why dont you just do this:

<div class="checkbox"> <label> {{ form.render('region', ['class': 'col-xs-4']) }} {{ form.label('region', ['class': 'col-xs-2']) }} </label> </div>

?



60.0k

Hi GunslerRage,

i also had this idea, but my output looks like this:

<div class="checkbox">
    <label>
        <label for="region" class="col-xs-2">Singles</label>            
           <input id="region" name="singles" class="col-xs-2" type="checkbox">
     </label>
  </div>

I am rendering the label in form.php.

Do you have another idea?

Rgds

Stefan

It dosent make any sense?

The just remove the <label> if form.php renders it for you? :-)



60.0k
edited Oct '15

the form.php renders this

    <label for="region" class="col-xs-2">Region</label>            
     <input id="region" name="region" class="col-xs-2" type="checkbox">

But i need this:

<label>       
       <input id="region" name="region" class="col-xs-2" type="checkbox">
 </label>

Maybe i have a flaw, but in bootstrap checkboxes are wrapped with label tag.

Rgds

Stefan

Oh sorry!

You just remove the label class:

{{ form.render('region', ['class': 'col-xs-4']) }} {{ form.label('region']) }}