AmarpremCool
AmarpremCool

Reputation: 37

How to hide field with label in ctp file in Cakephp?

<div><Strong>Name: </strong><?= $record['Childvaccination']['name']; ?></div>

When data is not coming then it is showing "Name:" only but I also want to hide name if data is not coming or it is empty. This is cakephp ctp file.

Upvotes: 0

Views: 113

Answers (1)

drmonkeyninja
drmonkeyninja

Reputation: 8540

You want to check if the value is empty or not and output accordingly:-

<?php if (!empty($record['Childvaccination']['name'])): ?>
    <div><Strong>Name: </strong><?= $record['Childvaccination']['name']; ?></div>
<?php endif; ?>

Upvotes: 2

Related Questions