Radio Button Selector Interface in Block Form
Permalink- One of the options is that the user can choose one "mode" that the block will display - there are 3 choices in the form of a radio button selector.
- When any of the 3 radio buttons are selected, corresponding input is displayed beneath it.
Now, I have had success with 2 options, but not 3. That is where I need help. Below is my code for the form.php file for the section I'm working on.
For the radio button selector, I have:
<div class="ccm-block-field-group"> <p> <?php echo $form->radio('lptype', 'time', $lptype, array('checked'=>'checked'))?> <?php echo $form->label('lptypeT', t('Time'))?> <?php echo $form->radio('lptype', 'countdown', $lptype)?> <?php echo $form->label('lptypeC', t('Countdown'))?> <?php echo $form->radio('lptype', 'random', $lptype)?> <?php echo $form->label('lptypeR', t('Random Number'))?> </p> </div>
And, for the 'wrapper' for each of the corresponding options:
<div class="ccm-block-field-group"> <div class="time-format"<?php if (($lptype == 2) || ($lptype == 3)) {echo " style=\"display:none\"";} ?>> CONTENT HERE </div> <div class="countdown-format"<?php if (($lptype == 1) || ($lptype == 3)) {echo " style=\"display:none\"";} ?>> CONTENT HERE </div> <div class="random-format"<?php if (($lptype == 1) || ($lptype == 2)) {echo " style=\"display:none\"";} ?>> CONTENT HERE </div> </div>
Is it possible to do this? If so, how do I make it work?
if you want unique divs, maybe
or something like that?
Alternatively, you could do this more elegantly with jquery:
and have the divs be like
type out in this forum window, so might not be accurate.
EDIT: woops, just realized countdown format was only one of the div classes. I used it for everything. you should get the idea though.