bootstrap-ui
bootstrap-ui copied to clipboard
Change default style configuration
How to change the default style configuration
im wondring if i could change the style while loading the plugin , for example if i would like to change class="btn-default" to something else without touching the source code of the plugin .
Thanks
The plugin employs the same string templating system that CakePHP core uses.
https://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses
Thanks for answer , still , i cant change checkbox class, this is my code
admin_form.php
<?php
return [
'button' => '<button class="btn btn-secondary btn-block mt-3" {{attrs}}>{{text}}</button>',
'checkboxContainer' => '<div class="icheck_minimal skin">{{content}}{{help}}</div>',
'checkbox' => '<input type="checkbox" class="icheck_minimal skin" name="{{name}}" value="{{value}}"{{attrs}}>',
'checkboxContainerError' => '<div class="icheck_minimal skin" has-error">{{content}}{{error}}{{help}}</div>'
];
?>
and my AppView.php
$this->loadHelper('Form', ['className' => 'BootstrapUI.Form',
'templates' => 'admin_form',
]);
and when i inspect the checkbox , i saw class="checkbox"
@josegonzalez
Can you gist your entire AppView?
Sure
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\View;
use Cake\View\View;
/**
* Application View
*
* Your application’s default view class
*
* @link https://book.cakephp.org/3.0/en/views.html#the-app-view
*/
class AppView extends View
{
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading helpers.
*
* e.g. `$this->loadHelper('Html');`
*
* @return void
*/
public function initialize()
{
$this->loadHelper('Form', [
'templates' => 'app_form',
'className' =>'Myform'
]);
$this->loadHelper('Paginator', ['templates' => 'paginator-templates']);
$this->loadHelper('Menu');
}
}
Are you loading CrudView or some other view class?
No at all , if i remove default style in your plugin source code , everything works fine but with $default checkbox not working
I have same problem with checkbox, if I use
<?php
$form_template = [
'checkbox' => '<div class="col-sm-10"><input type="checkbox" class="js-switch" name="{{name}}" value="{{value}}"{{attrs}}></div>',
'checkboxFormGroup' => '<div class="%s">{{label}}{{error}}{{help}}</div>',
'nestingLabel' => '<label class="col-sm-2 control-label" {{attrs}}>{{text}}</label>{{input}}'
];
$this->Form->setTemplates($form_template);
?>
not work, if I set template in control() it works
<?php
echo $this->Form->control('online', ['type'=>'checkbox','templates'=>[
'checkbox' => '<div class="col-sm-10"><input type="checkbox" class="js-switch" name="{{name}}" value="{{value}}"{{attrs}}></div>',
'checkboxFormGroup' => '<div class="%s">{{label}}{{error}}{{help}}</div>',
'nestingLabel' => '<label class="col-sm-2 control-label" {{attrs}}>{{text}}</label>{{input}}',
]]);
?>