Hide conditionally hidden fields from custom node template Case: I am using conditional fields module to hide some dependent fields based on the value of its dependee field. I have created a custom node--content-type.tpl.php template for my content type.

Field1

Field2


Here, Field2 is dependent on the value of Field1. Suppose in this case, Field2 is rendered only if Field1 has value 'jobs'. Otherwise, it is hidden from both node edit form and node page.

When using seven theme and its display(default or teaser) to view node, if the Field2 is hidden or the dependency was not triggered the Field2 is not rendered on the node page, which is correct.

But, when using my custom template, I am not been able to prevent the rendering of Field2 on my node. It is shown with its default value on the node.

Please help.

template code:

&lt;?php if(isset($content['field_job_type'][0]['#markup'])):?&gt;
              &lt;li&gt;
                &lt;p class=" no-margin "&gt;&lt;strong&gt;Job Type:&lt;/strong&gt; &lt;?php print $content['field_job_type'][0]['#markup'];?&gt;&lt;/p&gt;
              &lt;/li&gt;
            &lt;?php endif;?&gt;
Based on the comments:

generic template works, but custom does not

custom template overrides visibility rules


I would surmise that the problem is with the visibility, since the conditional field is likely only hidden, and not actually being removed - this would cause the code to execute every time, while in a standard render() it would remain hidden
Using Devel and specifically the dpm() function, I would find the element in the field array that manages the visibility of the field and use that as the basis for the if statement.

A suite of modules containing fun for module developers and themers