bootstrap-ui icon indicating copy to clipboard operation
bootstrap-ui copied to clipboard

Change default style configuration

Open ra7bi opened this issue 8 years ago • 8 comments

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

ra7bi avatar Sep 11 '17 17:09 ra7bi

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

davidyell avatar Sep 12 '17 15:09 davidyell

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"

ra7bi avatar Sep 12 '17 16:09 ra7bi

@josegonzalez

ra7bi avatar Sep 13 '17 05:09 ra7bi

Can you gist your entire AppView?

josegonzalez avatar Sep 13 '17 14:09 josegonzalez

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');
    }
}


ra7bi avatar Sep 14 '17 06:09 ra7bi

Are you loading CrudView or some other view class?

josegonzalez avatar Sep 14 '17 13:09 josegonzalez

No at all , if i remove default style in your plugin source code , everything works fine but with $default checkbox not working

ra7bi avatar Sep 15 '17 13:09 ra7bi

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}}',
]]);
?>

igorfelluga avatar Oct 06 '17 16:10 igorfelluga