Question

I have a form that when originally submitted, it goes into a page where a user can "preview" the item before posting it to the site. I have these 3 links, but I would like to change it from the default text links to image buttons that they can click on to perform these tasks.

  <?php echo link_to('Edit', 'ticket_edit', $ticket) ?>
  <?php echo link_to('Purchase', 'ticket_publish', $ticket, array('method' => 'put')) ?>
  <?php echo link_to("Cancel", 'ticket_delete', $ticket, array('method' => 'delete', 'confirm' => 'Are you sure you want to delete the item?')) ?>

So instead of "edit", "publish", and "cancel", I want it to display an image for each.

Was it helpful?

Solution

You can use

<?php echo link_to( image_tag( '<your image name>' ), 'ticket_edit', $ticket) ?>

and so on for the other links...

OTHER TIPS

You can use button_to ($name, $internal_uri, $options) (Symfony docs)

<?php echo button_to('Edit', 'ticket_edit', $ticket) ?>

but you cannot use an image as a button. However, this SO answer will give you a function you can use to get what you need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top