Reputation: 4469
I have tried this line to add class in cakephp form button, but class is not showing in html
<?= $this->Form->button(__('Login',['class'=>'login-btn'])); ?>
How can I add class in button ?
Upvotes: 3
Views: 5924
Reputation: 539
it has to be inside an array : try this
<?= $this->Form->button(__('Login'),array('class'=>'login-btn')); ?>
Upvotes: 0
Reputation: 2949
I think your example doesn't work, because the __()
Call shouldn't include the array for the options of the button. Please try the following:
<?= $this->Form->button(__('Login'),['class'=>'login-btn']); ?>
Upvotes: 11
Reputation: 13679
Have a try on this below:
<?php echo $this->Form->button('Login',['class'=>'login-btn']); ?>
A good reference here: Creating input elements
Update
__()
is for internalization. Using this will look in to your localization file and output it's corresponding translation. In your case, you include the options inside __()
which I think it will cause an error but if it didn't, it will look for it's translated version and also this means ['class'=>'login-btn']
is not considered as an option anymore.
Upvotes: 1