user1093405
user1093405

Reputation: 41

CakePHP 2.1 conditional statements in view.ctp

Can anyone please help with this. For some or other reason the !empty() in view.ctp does not seem to work.

I have 4 records where 'occupation' has text and another 2 records where there is nothing at all. If I use !empty() as below they all disappear and if I use empty() they all come back. What am I doing wrong?

Your help will be greatly appreciated.

<?php if (!empty($shoulderExamination['occupation'])):?>
    <dt><?php echo __('Occupation'); ?></dt>
    <dd>
        <?php echo h($shoulderExamination['ShoulderExamination']['occupation']); ?>
        &nbsp;
    </dd>
<?php endif; ?>

Upvotes: 0

Views: 900

Answers (1)

noslone
noslone

Reputation: 1289

Try

if (!empty($shoulderExamination['ShoulderExamination']['occupation']))

instead of

if (!empty($shoulderExamination['occupation']))

Upvotes: 1

Related Questions