Support the ongoing development of Laravel.io →
posted 11 years ago
Forms

I am making a jquery mobile application with laravel.

I know how to make one radiobutton with Form::macro

But what is the best way to make a button controller group just like in jqueryu mobile

For: example:

{{Form::macro('jradio', function($name, $id,$value)
{
    return ' <input type="radio" name='.$name.'id='.$id.'value='.$value.'>';
});
}}

 <form>
        <fieldset data-role="controlgroup">
        <input type="radio" name="radio-choice-v-2" id="radio-choice-v-2a" value="off">
        <label for="radio-choice-v-2b">1 Gering</label>
     
        <input type="radio" name="radio-choice-v-2" id="radio-choice-v-2b" value="other">
        <label for="radio-choice-v-2c">3 Belangrijk</label>
        
        <input type="radio" name="radio-choice-v-2" id="radio-choice-v-2c" value="other">
        <label for="radio-choice-v-2d">7 Ernstig</label>
      
        <input type="radio" name="radio-choice-v-2" id="radio-choice-v-2d" value="other">
        <label for="radio-choice-v-2e">15 Zeer ernstig</label>
        
        <input type="radio" name="radio-choice-v-2" id="radio-choice-v-2e" value="other">
        <label for="radio-choice-v-2f">40 Ramp</label>
       
        <input type="radio" name="radio-choice-v-2" id="radio-choice-v-2f" value="other">
    </fieldset>
    
</form>

If i replace the radio buttons with my selfmade macro then laravel would try and save all the radiobuttons right? Or does the controlgroup still work?

Last updated 2 years ago.
0

This is how i did it!

{{Form::macro('jradio2', function($name,$id,$value,$checked)
{
    return '<input type="radio" name='.$name.' id='.$id.' value='.$value.' checked='.$checked.' >';

});
}}

{{ Form::open(array('url' => 'gotomobilepage3', 'method' => 'post')) }}

    <div data-role="collapsible">
        <h3>Blootstellingsfrequentie(B)</h3>
   

        <fieldset data-role="controlgroup">
            
             <label for="radio-choice-v-2a">0 Nooit</label>
            {{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2a' ,'0',"checked") }} 
             <label for="radio-choice-v-2b">1/2 Zeer zelden {{'(<1x/jaar)'}}</label>
            {{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2b' ,'0.5',"") }} 
            <label for="radio-choice-v-2c">1 Zelden{{'(jaarlijks)'}} </label>
            {{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2c' ,'1',"") }} 
            <label for="radio-choice-v-2d">2 Soms{{'(maandelijks)'}}</label>
            {{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2d' ,'2',"") }}
            <label for="radio-choice-v-2e">3 Af en toen{{'(wekelijks)'}}</label>
            {{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2e' ,'3',"") }}
            <label for="radio-choice-v-2f">6 Regelmatig {{'(dagelijks)'}}</label>
            {{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2f' ,'6',"") }}
              <label for="radio-choice-v-2g">10 Voortdurend</label>
            {{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2g' ,'10',"") }}
        
    </fieldset>

Only thing is the checked property does not work properly.

Last updated 2 years ago.
0

Below that i have:


    </div>
     <div data-role="collapsible">
        <h3>Effect(E)</h3>
        <fieldset data-role="controlgroup">
             <label for="radio-choice-v-2a">0 Geen</label>
            {{ Form::jradio2('radio_effect','radio-choice-v-2a' ,'0',"") }} 
             <label for="radio-choice-v-2b">1 Gering</label>
            {{ Form::jradio2('radio_effect','radio-choice-v-2b' ,'1',"") }} 
            <label for="radio-choice-v-2c">3 Belangrijk</label>
            {{ Form::jradio2('radio_effect','radio-choice-v-2c' ,'3',"") }} 
            <label for="radio-choice-v-2d">7 Ernstig</label>
            {{ Form::jradio2('radio_effect','radio-choice-v-2d' ,'7',"") }}
            <label for="radio-choice-v-2e">15 Zeer Ernstig</label>
            {{ Form::jradio2('radio_effect','radio-choice-v-2e' ,'15',"") }}
            <label for="radio-choice-v-2f">40 Ramp</label>
            {{ Form::jradio2('radio_effect','radio-choice-v-2f' ,'40',"") }}
    </fieldset>

    </div>

    <div data-role="collapsible">
        <h3>Waarschijnlijkheid(W)</h3>

        <fieldset data-role="controlgroup">

           
            <label for="radio-choice-v-2a">1/10 Bijna niet denkbaar</label>
            {{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2a' ,'0.1',"") }} 
             <label for="radio-choice-v-2b">1/4 Praktisch onmogelijk</label>
            {{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2b' ,'0.25',"") }} 
            <label for="radio-choice-v-2c">1/2 Denkbaar, maar onwaarschijnlijke</label>
            {{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2c' ,'0.5',"") }} 
            <label for="radio-choice-v-2d">1 Onwaarschijnlijk, mogelijk in grensgeval</label>
            {{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2d' ,'1',"") }}
            <label for="radio-choice-v-2e">3 Ongewoon</label>
            {{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2e' ,'3',"") }}
            <label for="radio-choice-v-2f">6 Zeer wel mogelijk</label>
            {{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2f' ,'6',"") }}
              <label for="radio-choice-v-2g">10 Te verwachten</label>
            {{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2g' ,'10',"") }}
          
        
    </fieldset>
    

    </div>
    {{Form:: submit("VERDER")}}
         {{ Form::close() }}

    @stop

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

JeffreyR jeffreyr Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.