So, I'm at work (working with sensitive data, I can add for posterity), and the powers that are being solved, we need to use the whole powerful and least documented new Cakephp 3.0 tool (beta at this time).
Edit: My goal is to create several different templates for forms that invoke forms or input methods through the template. This is actually not a good example. Setting up the FormHelper template Usage: As you can see from the book (and nowhere else on the Internet), a very short documentation is as follows: http://book.cakephp.org/3.0/en/core-libraries/helpers/form.html#customizing-the- templates-formhelper-uses
The site says that you can use the template method and then give an indefinite "use":
$myTemplates = [ 'inputContainer' => '<div class="form-control">{{content}}</div>', ];
$ this-> form-> templates ($ myTemplates);
He then says that you can use the input () method, for which it gives no example. Last but not least, the custom FormHelper template should allow you to “create” or “create” as many of these custom forms as possible, but they provide no example how to do this !? lulwut?
I can easily use it once, as their example, but where is the power in one custom template? It doesn't do me any good.
So, for a new possible solution, I will try to get a new error.
I get this error (in my view) (from the following code):
Fatal error Error: Class 'Configure' not found
//within bootstrap.php Configure::write('templates', [ 'shortForm' => [ 'formstart' => '<form class="" {{attrs}}>', 'label' => '<label class="col-md-2 control-label" {{attrs}}>{{text}}</label>', 'input' => '<div class="col-md-4"><input type="{{type}}" name="{{name}}" {{attrs}} /></div>', 'select' => '<div class="col-md-4"><select name="{{name}}"{{attrs}}>{{content}}</select> </div>', 'inputContainer' => '<div class="form-group {{required}}" form-type="{{type}}">{{content}} </div>', 'checkContainer' => '',], 'longForm' => [ 'formstart' => '<form class="" {{attrs}}>', 'label' => '<label class="col-md-2 control-label" {{attrs}}>{{text}}</label>', 'input' => '<div class="col-md-6"><input type="{{type}}" name="{{name}}" {{attrs}} /></div>', 'select' => '<div class="col-md-6"><select name="{{name}}"{{attrs}}>{{content}}</select> </div>', 'inputContainer' => '<div class="form-group {{required}}" form-type="{{type}}">{{content}} </div>', 'checkContainer' => '',], 'fullForm' => [ 'formstart' => '<form class="" {{attrs}}>', 'label' => '<label class="col-md-2 control-label" {{attrs}}>{{text}}</label>', 'input' => '<div class="col-md-10"><input type="{{type}}" name="{{name}}" {{attrs}} /> </div>', 'select' => '<div class="col-md-10"><select name="{{name}}"{{attrs}}>{{content}}</select> </div>', 'inputContainer' => '<div class="form-group {{required}}" form-type="{{type}}">{{content}} </div>', 'checkContainer' => '',] ]); //within my view <?php $this->Form->templates(Configure::read('templates.shortForm')); ?>
Old update : I added
use "Cake\Core\Configure;"
in my view, and everything works fine, but I would like to add this to the corresponding file in the hierarchy, so I don’t need to add this to all the views,
Unless, of course, this causes performance problems for the entire application. Does anyone know which file it should go to? Regards and TIA!
New update . I just figured it out. So simple! check out my answer below! Hope this helped someone