0
votes

I'm learning CakePHP 3.7.7 and I'm trying to configure it to use Bootstrap 4. Here what I did:

  1. installed bootstrap4 plugin, following the docs
  2. added in src/Template/Layout/default.ctp the CDN links as described here
  3. added in src/View/AppView.php:

    $this->loadHelper('Html');
    $this->loadHelper('Form');
    $this->loadHelper('Flash');
    
  4. baked with this command: bin/cake bake all -t LilHermit/Bootstrap4 MyTable

When I open the URL /MyTable the page partially loads with the following warning:

Warning (512): Method Cake\View\Helper\HtmlHelper::button does not exist [CORE/src/View/Helper.php, line 117]

What should I further do?

1
What version of CakePHP are you using? - Chris White
@ChrisWhite CakePHP 3.7.7 - Mark
Seems to be a bug in the Bootstrap plugin; as the error says the HtmlHelper does not have a button method. - Chris White
Well, is there a more reliable way to configure CakePHP to bake Bootstrap4-based Templates? - Mark
I can't answer that, unfortunately; never did a lot of baking with CakePHP and really stuck to the backend for the most part. Perhaps someone else can. Sorry :( - Chris White

1 Answers

0
votes

I had the same warning when I forgot to initialize AppView. The recomended way for configuring it is through extending it from BootstrapView and make sure that your initialize() method calls parent initialize(). Here is my working AppView.php

src/View/AppView.php:

<?php
namespace App\View;

use LilHermit\Bootstrap4\View\BootstrapView;

class AppView extends BootstrapView
{
    public function initialize()
    {
        parent::initialize();
    }
}