Many months ago I had asked for help on the symfony forums on how to create a delete button using either the link_to() or button_to() method. I had tried but was always getting validation errors. Today a person asked whether anyone had figured out a solution. It prompted me to do more research into symfony’s core code and found a solution (though the solution wasn’t in the core code).
Original delete text link code:
echo link_to( 'Delete', 'state/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?') );
New delete BUTTON link code:
echo link_to( '<button>Delete</button>', 'state/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?') );
Till Next Time
Tags: delete button, delete link, php, quickie, symfony, symfony 1.2