DEV Community

sachiko-kame
sachiko-kame

Posted on

CakePHP Form button Customize

how to

  • Add the class you want to adapt to create
<?= $this->Form->create(null, ['class'=> 'aaa' , 'url' => ['controller' => 'Advices', 'action' => 'heart']]); ?>
<?= $this->Form->hidden( 'advice_id', ['value'=>$advices->id ]); ?>
<?= $this->Form->button(__('Heart')) ?>
<?= $this->Form->end() ?>
Enter fullscreen mode Exit fullscreen mode
  • How to write on the button of the class
.aaa .button, .aaa button, .aaa input[type='button'], .aaa input[type='reset'], .aaa input[type='submit'] .aaa {
    background-color: #db116c;
    border: 0.1rem solid #db116c;
}
Enter fullscreen mode Exit fullscreen mode
  • Appearance after change

Appearance after change


A little more

  • Image of unpressed heart
<?= $this->Form->button(__('♡')) ?>
Enter fullscreen mode Exit fullscreen mode
.aaa .button, .aaa button, .aaa input[type='button'], .aaa input[type='reset'], .aaa input[type='submit'] .aaa {
    background-color: #f1f2f4;
    border: 0.1rem solid #606c76;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    font-size: 2rem;
    color: #606c76;
}
Enter fullscreen mode Exit fullscreen mode

Alt Text


  • Image of pressed heart
<?= $this->Form->button(__('♥')) ?>
Enter fullscreen mode Exit fullscreen mode
.aaa .button, .aaa button, .aaa input[type='button'], .aaa input[type='reset'], .aaa input[type='submit'] .aaa {
    background-color: #db116c;
    border: 0.1rem solid #db116c;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    border-radius: 50%;
    font-size: 2.3rem;
    color: white;
}
Enter fullscreen mode Exit fullscreen mode

Alt Text


Top comments (4)

Collapse
 
yellow1912 profile image
yellow1912

Cakephp is still a thing? It was my first php framework but I'm glad I made the switch.

Collapse
 
sachikokame profile image
sachiko-kame

Are you currently using a different framework?
A different framework is good too!

I want to use cakePHP! I'm using it because I thought!
I am writing an article hoping that there is the same person.

Collapse
 
yellow1912 profile image
yellow1912

I used cakephp when it first came out. It was the php version of rails. I used to use rails so I was very excited. There were many issues back then, many missing documents and features. Then Symfony came out and I made the switch.

Thread Thread
 
sachikokame profile image
sachiko-kame

Thank you for your reply!

Sounds good!
It's a cool framework!
I want to use it someday!

There are various, but
I'm in love with the name cakePHP, so
I want to get along with cakePHP a little more!