Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default style configuration #200

Open
ra7bi opened this issue Sep 11, 2017 · 8 comments
Open

Change default style configuration #200

ra7bi opened this issue Sep 11, 2017 · 8 comments

Comments

@ra7bi
Copy link

ra7bi commented Sep 11, 2017

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

@davidyell
Copy link
Member

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

@ra7bi
Copy link
Author

ra7bi commented Sep 12, 2017

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
Copy link
Author

ra7bi commented Sep 13, 2017

@josegonzalez

@josegonzalez
Copy link
Member

Can you gist your entire AppView?

@ra7bi
Copy link
Author

ra7bi commented Sep 14, 2017

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


@josegonzalez
Copy link
Member

Are you loading CrudView or some other view class?

@ra7bi
Copy link
Author

ra7bi commented Sep 15, 2017

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

@igorfelluga
Copy link

igorfelluga commented Oct 6, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants