Forum
custom markup input radio
Hi,
I have form with a more complicated markup for radio buttons wich I can't create with way perch handles them. Is there a way to disable the normal behavior? I need to create a markup like this:
<div class="product-option">
<perch:input type="radio" class="radio-options" id="option-1" name="product-1-option" value="cardboard" label="cardboard" checked/>
<label for="option-1" >
<img src="/images/configurator/cardboard01.png" alt="irgendwas">
<span>cardboard</span>
</label>
</div>
etc.
Which part isn't working?
I didn't find away to create the above code with the usual code for radio buttons form the docs, where perch automatically creates labels. Every label needs to have it's own image and the value needs to be wrapped in a span.
Here is a code that should illustrate the problem more clearly. Perch alway adds another extra label. Template:
Output:
I see what you mean.
type="radio"
outputs a set of radio buttons, not an individual button. If you use it to create a number of single-item sets they won't actually behave like radio buttons.Do have an idea for a work around?
You could use
wrap="div.product-option"
to wrap the button in a div, but I'm not sure about the image.Mh, I see. Than I probably go with checkboxes and fake the radio button behavior with jQuery, but that's not ideal. I was thinking of creating an extra field type, but that's a bit over my head.
If you're going down the JavaScript route anyway, you could add the images that way - that would fall back better without JS.
Yes, that's was also my concern, maybe I do it that way.