I am in the process of creating a new database table with the following structure:
CREATE TABLE IF NOT EXISTS `videothek9`.`movies` (
`id` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(45) NOT NULL,
`release_year` VARCHAR(45) NOT NULL,
`available` TINYINT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`))
and using the cakephp bake console to generate it.
This is an example of how the standard movies/index page will look like:
https://i.sstatic.net/olsK2.jpg
The "available" field can have values of 0 or 1. I want to display specific images instead, such as a checkmark tick or a red x-mark. Unfortunately, the cakephp cookbook (html helper section) couldn't provide much assistance...
Below is a snippet of the view code:
<?php foreach ($movies as $movie): ?>
<tr>
<td><?php echo h($movie['Movie']['id']); ?> </td>
<td><?php echo h($movie['Movie']['title']); ?> </td>
<td><?php echo h($movie['Movie']['release_year']); ?> </td>
<td><?php echo h($movie['Movie']['available']); ?> </td>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('action' => 'view', $movie['Movie']['id'])); ?>
<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $movie['Movie']['id'])); ?>
<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $movie['Movie']['id']), array(), __('Are you sure you want to delete # %s?', $movie['Movie']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
Is it possible to use a simple PHP if/else statement in the Movies Controller to achieve this?