I encountered an issue with the Form helper when trying to add a class to a Form->postLink
. Here is what I attempted:
<?php echo $this->Form->postLink(
'Delete',
array('action' => 'delete', $location['Location']['id']),
array('class' => 'btn btn-small btn-primary'),
array('confirm' => 'Are you sure?'));
?>
I experimented with adding the class array after the confirm array and before the action array, but without success. The error message I received was:
Notice (8): Array to string conversion [CORE/Cake/View/Helper/FormHelper.php, line 1786]
The problematic line reads as follows:
$options['onclick'] ="if(confirm('{$confirmMessage}')) { {$onClick} }";
When placing the class array after the action, the class gets applied to the button but triggers the aforementioned error. Placing it before the action results in the class not being applied and the error persisting. Despite extensive research online and in documentation, I have yet to find a solution to this puzzling issue...