A quick question on radio buttons (again)

3 messages Options
Embed this post
Permalink
dmitrybelyakov

A quick question on radio buttons (again)

Reply Threaded More More options
Print post
Permalink
Hello,

I know this had been raised a million times but i think i broke my head trying to get through the reference guide for 2 days. Now i google and see a lot of people complain about lack of useful examples in the docs so thought it it would be ok if i post on the topic again. Hope this will be a quick one:



What i want to is have my radio buttons with small images like this:



<input type="radio" name="cardType" id="cardType-gold">
    <label for="cardType-gold">
        <img src="" /> Gold card
    </label>


What do I need for that? A custom view helper? A custom decorator? Can i do it by configuration?



Thanks a lot!
Dmitry.
lightflowmark

Re: A quick question on radio buttons (again)

Reply Threaded More More options
Print post
Permalink
A custom decorator (although you may be able to piece it together with the Label decorator and the HtmlTag decorator).


One approach would be to extend the Label decorator; pass the URL of the image as an option to your extended label decorator and have it render the image tag.

There's probably a better way, but that will definitely work.

Have you seen Matthew's blog posts on form decorators?
http://weierophinney.net/matthew/plugin/tag/decorators


M






dmitrybelyakov wrote:
Hello,

I know this had been raised a million times but i think i broke my head trying to get through the reference guide for 2 days. Now i google and see a lot of people complain about lack of useful examples in the docs so thought it it would be ok if i post on the topic again. Hope this will be a quick one:



What i want to is have my radio buttons with small images like this:



<input type="radio" name="cardType" id="cardType-gold">
    <label for="cardType-gold">
        <img src="" /> Gold card
    </label>


What do I need for that? A custom view helper? A custom decorator? Can i do it by configuration?



Thanks a lot!
Dmitry.
dmitrybelyakov

Re: A quick question on radio buttons (again)

Reply Threaded More More options
Print post
Permalink

lightflowmark wrote:
A custom decorator (although you may be able to piece it together with the Label decorator and the HtmlTag decorator).


One approach would be to extend the Label decorator; pass the URL of the image as an option to your extended label decorator and have it render the image tag.

There's probably a better way, but that will definitely work.

Have you seen Matthew's blog posts on form decorators?
http://weierophinney.net/matthew/plugin/tag/decorators


M
Yes, i did but still got a lot of confusion on how to use it properly. Right now i disabled escaping for that field and directly appended the image to the label value. But that doesn't look very 'clean', i think i'll try that approach with decorators.

Seems a bit like headache to have to write classes and 'extend' in order to do such simple and quick things. But never mind - that's just me complaining. Anyways - thanks for your reply, i'll try this to make my form more clean.

Dmitry.