I want to create a CCK field in my custom content type where the value (a yes/no select list) will or will not display a defined (static) line of HTML once selected. CCK fields allow for custom PHP, has anyone done this?

For example. Lets say I have a field named Disclaimer with 2 values, "yes" or "no".

If "yes" is selected, then a predefined line of text (the HTML disclaimer) is displayed on the page. If "no" is selected, then HTML will not be shown.

Can anyone show me how to do this?

Comments

WorldFallz’s picture

I used the custom_formatters module to make a field formatter that added the value of the field as a class to the select list field element-- then I used that class ("yes" or "no") to target the field with css and display: none;.

rewted’s picture

Thanks for the suggestion. But as I indicated, I'm looking to do this in PHP, not with another module.

mchohan’s picture

You could fire some jquery based on which option is clicked? Then if yes is clicked, show you message in a hidden div.

rewted’s picture

I was thinking something more along the line of creating a custom field (single on/off checkbox) that when checked as "yes" will display some html on a node and if "no" will display nothing. I just don't know how to do the PHP portion in my node template.