Adding a link INTO checkbox list options

Permalink
Hi all, i wonder if there's any possibility out there to include a link in HTML format inside the field of checkbox list options, block Form (I attach an image of this field).

Everytime I add a link here including quotation marks (") the block gets a little crazy, and if I use simple quotation marks to substitute the href, the link won´t work

Any solutions? Thanks in advance

1 Attachment

thenine
View Replies:
bbeng89 replied on at Permalink Reply
bbeng89
I don't know if this is really a good thing to do or not, but the easiest solution would probably be to just use single quotes instead of double quotes in your anchor tag. So inside the options text area you could have:
<a href='http://yoursite.com'>Your Text</a>


And that should work.
thenine replied on at Permalink Reply
thenine
Thanks for the answer bbeng, that's the first thing i tried but it didn´t work. Don´t know if this is caused by the post-processing of the block when you hit the save button.
bbeng89 replied on at Permalink Reply 1 Attachment
bbeng89
Hm, what version of concrete5 are you running? I'm on 5.6.1.2 and it worked fine for me. I also looked in the database and saw that it is just storing the options exactly as I entered them.

Also, for me, the line of code that spits out each option looks like this:
$html.= '  <div class="checkboxPair"><input name="Question'.$msqID.'_'.$i.'" type="checkbox" value="'.trim($options[$i]).'" '.$checked.' /> '.$options[$i].'</div>'."\r\n";


So you can see it just does $options[$i] which is just spitting out what is in the database.

Attached is an image of what my "Add" form looks like and the result. Does everything look the same as what you did?
thenine replied on at Permalink Reply
thenine
Let me amend this answer: Technically this works.

What I´m trying to reach it´s to include a link that opens in a JS popup. Just like a privacy or legal terms checkbox.

Copying the html code for a simple popup just doesn´t work. It destroys the sentence, so adding this, for example

<a onclick="window.open('http://yoursite.com/your_popup_page.html','Política de privacidad','width=320,height=480');return false;" href="http://yoursite.com/your_popup_page.html">legal terms</a>


Appears like this:

Legal Terms "> Legal Terms (the second part from including the link)

And if i replace this using single quotas, like this:

<a onclick='window.open('http://yoursite.com/your_popup_page.html','Política de privacidad','width=320,height=480');return false;' href='http://yoursite.com/your_popup_page.html'>legal terms</a>


simply doesn´t work
bbeng89 replied on at Permalink Reply
bbeng89
Ahh, okay I see the issue. I'm thinking it could be done but you might have to override the view and the controller for the form block so that it does html encoding/decoding on the options.

Is this checkbox just going to be something that is at the end of the form? Also, do you have to store that they checked it in the database? If not, you could probably just create a custom template and append the legal terms link to the bottom.
thenine replied on at Permalink Reply
thenine
That's what I did as a temporary solution! :)
bbeng89 replied on at Permalink Reply
bbeng89
Well the real problem is that whatever you enter as the text for the option is also that option's value. So if you enter:
<a onclick="window.open('http://yoursite.com/your_popup_page.html','Política de privacidad','width=320,height=480');return false;" href="http://yoursite.com/your_popup_page.html">legal terms</a>


As an option, that entire string would be the value of the input. So it would look like:
<input type="checkbox" value="<a onclick="window.open('http://yoursite.com/your_popup_page.html','Política de privacidad','width=320,height=480');return false;" href="http://yoursite.com/your_popup_page.html">legal terms</a>" />

Which is obviously weird and not ideal. I think your temporary solution of using a custom template might be your best bet unless anyone else has any other ideas.
thenine replied on at Permalink Reply
thenine
Thanks bbeng!
JohntheFish replied on at Permalink Reply
JohntheFish
You can do this off-the-shelf with my Magic Tipple addon.

http://www.concrete5.org/marketplace/addons/magic-tipple/...

Create the form without the link, just the checkbox with text like "I have read and agree to the terms and Conditions"

Then add a Magic Tipple block with a matching key:
"I have read and agree to the terms and Conditions"
Followed by the text or html for the details of the terms and conditions.

You can set the tip popup to show on hover or click, and optionally have it insert an icon. There are many different tip styles to choose from.

When the page renders in the browser, the tipple block will find the keyed text, mark it, attach an event handler and popup the tip when clicked. The form will submit as before without even noticing the tip is there.
thenine replied on at Permalink Reply
thenine
This is definitely NOT what i´m looking for. But thanks for the advice.
JohntheFish replied on at Permalink Reply
JohntheFish
I obviously misunderstood your requirement. Can you explain what I got wrong please.
thenine replied on at Permalink Reply
thenine
I want the link to be included into the checkbox option, not outside the form. The checkbox it´s a mandatory field in the form.
JohntheFish replied on at Permalink Reply
JohntheFish
Thats what tipple does. It doesn't render text like other blocks do, but instead loads some hidden text and JavaScript. After a page is loaded it uses JavaScript to look for the keyed text already on the page (such as your checkbox option) and turn that keyed text into a link to a popup tip.

So your checkbox label will be turned into a link to a popup. Rather than a checkbox with a plain label, you will have a checkbox where the label is a link. When you click the link, you get the popup.

You can see it in action adding a glossary to my home page athttp://www.c5magic.co.uk/ . My page doesn't add tips within a form, but the process is exactly the same.

Amongst the popup options is a modal dialog box. You can also select to have a tip auto-show as the page is loaded, so it would start with the T&Cs showing.
JohntheFish replied on at Permalink Reply
JohntheFish
I have set up a quick example of a popup added to a form element here:

http://www.c5magic.co.uk/add-ons/magic-tipple/examples/...
thenine replied on at Permalink Reply
thenine
Hi Johnthe, one question ¿Can the normal form block be validated after adding a checkbox using your addon?
JohntheFish replied on at Permalink Reply
JohntheFish
Yes, the way the form submits and validates remains unaltered. All that changes is how it appears on the page.

Its not my addon that adds the checkbox. You add the checkbox as part of the form. My addon simply piggy-backs the popup onto it.
anchoredbutterfly replied on at Permalink Reply
anchoredbutterfly
Hi there, I see this is an older discussion, but I am having this exact issue now...
Do you think you might share your solution, so I could use it as well?

Thanks,
Sharon