Code Monkey home page Code Monkey logo

cakephp3-bootstrap-helpers's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cakephp3-bootstrap-helpers's Issues

PHP notice when creating an input

Creating an input like this:

$this->Form->input("domain");

while output a notice: Undefined index: input [ROOT/plugins/Bootstrap3/src/View/Helper/BootstrapFormHelper.php, line 182]

New feature for custom input file

Hi,
One thing I find really stupid about input file is to not be able to clear the selected file.
So we can find many various solutions but one which seems to be the best is that very simple one http://jsfiddle.net/Xotic750/pfeBs/
And despite some comments, it perfectly works on IE11, don't know on previous version and FF and Chrome.

So, as 'useCustomFileInput_2' => true maybe, would it be possible to have a file input with a button which toggles between 'Browse' (or better, the given label) and 'Delete' with color 'danger' (or better, another given label)?

Regards,
Alain

Ajax load Porblem

I'm developing a small backend with your Helpers, but when i try to get some content via ajax the inputs get original Cake php Form structure

<div class="input text"><label for="images-0-description">Description</label><input type="text" name="images[0][description]" id="images-0-description"></div>

instead of

<div class="form-group text"><label class=" control-label" for="images-0-description">Description</label><input class="form-control" type="text" name="images[0][description]" id="images-0-description"></div>

thats normally loaded

Trait error

When i update bootstrap3 plugin and edit names from Bootstrap3 to Bootstrap. I got this error.

Error: Trait 'Bootstrap3\View\Helper\BootstrapTrait' not found
File pathToProject\vendor\holt59\cakephp3-bootstrap3-helpers\src\View\Helper\BootstrapHtmlHelper.php
Line: 29

But BootstrapTrait is in same namespace, i do see reason for not working. (Sorry for my english)

Flash errors

Hello,
I propose to add the flash media error in your pack :)

Flash Helper Error

Hey, I have added this to my AppController.php

public $helpers = [
        'Html' => [
            'className' => 'Bootstrap.BootstrapHtml'
        ],
        'Form' => [
            'className' => 'Bootstrap.BootstrapForm',
            'useCustomFileInput' => true
        ],
        'Paginator' => [
            'className' => 'Bootstrap.BootstrapPaginator'
        ],
        'Modal' => [
            'className' => 'Bootstrap.BootstrapModal'
        ],
        'Flash' => [
            'className' => 'Bootstrap.BootstrapFlash'
        ]
    ];

I am getting an error whenever the flash is supposed to be displayed.

Element/.ctp 

Cake\View\Exception\MissingElementException

Does the helper automatically apply to

$this->Flash->error(__('The tag could not be saved. Please, try again.'));

Or did I miss a step?

Thanks,

Paginator numbers

How can I use icon for prev/next ?

Is it possible to use the paginator like this :

<?= $this->Paginator->numbers([
        'prev'=>['title'=>$this->Html->icon('chevron-left'),'escape'=>false],
        'next'=>['title'=>$this->Html->icon('chevron-right'),'escape'=>false]]); ?>

Proposal :

if (isset($options['prev'])) {
    $title  = '';
    $opt    = [];
    if(is_array($options['prev'])){
        $opt    = $options['prev'];
        $title  = $opt['title'];
        unset($opt['title']);
    }else{
        $title = $options['prev'];
    }
    $options['before'] .= $this->prev($title,$opt) ;
}

dateWidget template is not the same over time

I have a Reservations model that require a start date and end date.
Using the FormHelper in the simplest way

<fieldset>
    <legend><?= __('Request reservation') ?></legend>
<?php
    echo $this->Form->input('date_start', ['type' => 'date']);
    echo $this->Form->input('date_end', ['type' => 'date']);
?>
</fieldset>

gives this result
1

Adding some debug in the date function returned this
2

If I reset the previous template after the call to parent::date it works :)

public function date($fieldName, array $options = []) {
    $fields = ['year' => true, 'month' => true, 'day' => true];
    $prev_template = $this->templates('dateWidget');
    // debug('dateWidget: before '.$this->templates('dateWidget'));
    $this->templates([
        'dateWidget' => $this->_getDatetimeTemplate($fields, $options)
    ]);
    // debug('dateWidget: after '.$this->templates('dateWidget'));
    $return = parent::date($fieldName, $options);
    $this->templates(['dateWidget' => $prev_template]);
    return $return;
}

I hope I helped. It's my first time reporting an issue 👍

Duplicated attribute class when adding custom classes

Hi,

When adding a custom class to an input the attribute class is added twice.

$this->Form->input('name',array('class'=>'input-lg'))

Returns the following

<div class="form-group text">
    <label class="control-label "  for="name">Name</label>
    <input type="text" name="name" class="form-control input-lg"  class="input-lg" id="name" />
</div>

The attribute class exists two times. Most browser don't care about it, but it's not W3C valid and a bit confusing.

Templates for forms are not working

I saw someone previously asked how to use templates but when I tried to use myself to add a class to the error messages it didn't work.

The example given was:

public $helpers = [
    'Form' => [
        'className' => 'Bootstrap3.BootstrapFormHelper',
            'templates' => [
                'dateWidget' => '{{day}}{{month}}{{year}}{{hour}}{{minute}}{{second}}{{meridian}}'
            ]
    ]
];

so in my code:

public $helpers = [
    'Form' => [
        'className' => 'Bootstrap.BootstrapForm',
        'templates' => [
            'error' => '<span class="help-block error-message">{{content}}</span>'
        ],
    ],
];

but my error messages did not change. I still only have the class .help-block (which is not helpful for styling if you plan to use .help-block for information purposes in your form)

NavbarHelper - Calling addClass with Array throws notice

The following code

echo $this->Navbar->create(
    'The Project',
    [
        'responsive' => true,
        'fluid' => true,
        'fixed' => 'top'
    ]
);
echo $this->Navbar->beginMenu(['class' => 'navbar-right']);
    echo $this->Navbar->link(__('Exit'), ['controller' => 'Users', 'action' => 'logout']);
echo $this->Navbar->endMenu();
echo $this->Navbar->end();

throws the following notice
screenshot_20150723_134210

if I change the beginMenu line in level 0:

$options = $this->addClass ($options, ['nav', 'navbar-nav']);

to this

$options = $this->addClass ($options, 'nav navbar-nav');

then it works

Validation : Array to string conversion in CakePHP 3.1.4

i get this notice in the most recent CakePHP version 3.1.4 but no Validation message:

Notice (8): Array to string conversion [ROOT\vendor\holt59\cakephp3-bootstrap-helpers\src\View\BootstrapStringTemplate.php, line 70]

best regards

escape horizontal Form

Hi,

When we use Form->create(...., ['horizontal' => true']), is it possible to ask a specific input to ignore 'horizontal' => true?
Just because that cause a problem with one of the plugin I use.

Form template example

Hello,
I'm pretty new with CakePHP. Do you have an example how to use form element template with your helper? In my specific case, in my form, there is a birth date to fill, and I would like to use this template:

'dateWidget' => '{{day}}{{month}}{{year}}'

instead of

'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}'

Thanks for your help.

icon in breadcrumb

Hello,
I currently am using the helper in one of my projects, and I was wondering if it was possible to add the possiblity to use icons in the breadcrumbs ?
like this, by example :

echo $this->Html->getCrumbList(null, $this->Html->icon('home'));

Request is being black holed when using useCustomFileInput => true

Hi, I noticed that when I enabled useCustomFileInput my request started being black holed.

The only way I found to get over this issue was to change the plugin as follows:

File: BootstrapFormHelper.php
Line: 447

Code before:

    $options += ['secure' => true];

Code after:

    $options += ['secure' => false];

I don't have time to investigate further. So, at least, I think it would be great if this setting is taken from the $options set when using the helper.

Example:

    $this->Form->input('image', ['type' => 'file', 'secure' => false]);

Any thoughts?

`btn-default` is added even when `bootstrap-type` is set

This code:

<?= $this->Form->submit('Login', ['bootstrap-type' => 'primary']) ?>

Generates this HTML:

<input type="submit" value="Login" class="btn btn-default btn-primary">

Note that there is btn-primary and btn-default. It don't causes any problems at the moment, but I'm pretty sure this is not allowed by Bootstrap.

Help text option to inputs

Type: Feat. request

The same awesome job that you did putting append and prepend options I think you could put a help text option that insert after the input a text, something like that:

$this->Form->input('name', ['helpText' => 'bla bla bla');
//Html generated
//<input ...><p class="help-block">bla bla bla</p>

Radio buttons

Hi,
I would like to know if there is a way to display radio buttons one above the others.

Thks.

Wrapping Div Un-Editable...

In Cake2, I could use the 'div' options to edit the wrapping div (add classes or an ID or whatever else) but right now the .form-group div is hard-coded... I don't know how to make that edit myself...

Bake?

Hola

Seria muy util tener el comando el bake con el template

Radios in Horizontal Form

In horizontal forms, radio boxes are arranged left-adjusted.

Is it possibe to get following output for radioboxes?

<input type="hidden" value="" class="form-control " name="favorite_color">
<div class="form-group">
  <label for="username" class="col-md-2 control-label ">Favorite Color</label>
  <div class="col-md-6">
    <div class="radio">
      <label for="favorite-color-r">
        <input type="radio" id="favorite-color-r" style="color:red;" value="r" name="favorite_color">Red
      </label>
    </div>
    <div class="radio">
      <label for="favorite-color-u">
        <input type="radio" id="favorite-color-u" style="color:blue;" value="u" name="favorite_color">Blue
      </label>
    </div>
    <div class="radio">
      <label for="favorite-color-g">
        <input type="radio" id="favorite-color-g" style="color:green;" value="g" name="favorite_color">Green
      </label>
    </div>
  </div>
</div>

This would give us the radioboxes in the 2nd column as for other form elements in horizontal forms.
Or did I miss an existing feature?

Cheers,
Peter

Form buttons with icons not possible

This does not work as intended:

<?= $this->Form->submit($this->Html->icon('check').' '.__('Save'),
        ['bootstrap-type' => 'primary', 'escape' => 'false']) ?>

The escape option is ignored so the HTML rendered by icon() is escaped.

In general an icon option for buttons might be nice as well. I assume it is a common use-case.

Problem with date input

if i try to insert 2 date input on my form only the first one is displayed.
the HTML code of the second one is completly missing

Small problem when not using composer

If you simply clone the repository into plugins/Bootstrap3 it was necessary for me to use
Plugin::load('Bootstrap3', ['autoload' => true]);
instead of just
Plugin::load('Bootstrap3');
in config/bootstrap.php

Otherwise i get the following error:
image

Maybe this should be added to the README.md

Cheers!

Checkbox issue in basic form example

Thanks for those helpers it's saving a lot of time for our dev team.

However we have an issue with basic form and checkbox input. The helper add a .form-group div element which wrap .checkbox div element.

It break some advanced form building and we have to had manually a new template string for this case.

It should be awesome if your helper can improve this feature and dynamicaly add the wrapping form-group depending on the case of utilisation.

Allow overwriting the id of a search form

Current the input in a search form created with FormHelper::searchForm has always the default id of search. It would be nice if one could change that, e.g. if you want to have more than one form on the same page.

12 hour 'timeFormat' on 'datetime' input does not show AM/PM options

Let me start by saying I'm super glad you made these helpers, they rock :)

I'm having an issue where I display an input for a 'datetime' field using 12 hour timeFormat parameter, but the displayed box only shows 12 hours and does not allow selection of AM or PM. Here is the code I'm using to display the input field:

echo $this->Form->input('start_time', ['type' => 'datetime', 
                                                     'interval' => 5,
                                                     'minYear' => date("Y") - 1,
                                                     'maxYear' => date("Y"),
                                                     'timeFormat' => 12,
                                                     'label' => "Start Date and Time"]);

And here is an image of the produced output:

datetime-12hour-timeformat-bug

No way to modify input size

Hey,
Really nice plugin here, but I can't seem to find any way to change input size (input-lg, input-sm, input-xs). If I provide a "class" option to Form->input, it simply ignores it.

_groupTemplate() misses templateVars support

The support for templateVars option was added in CakePHP 3.1.0. In the FormHelper you can find it here:
https://github.com/cakephp/cakephp/blob/928beba6f76c6d1e884ae26f42c86a25717a1a85/src/View/Helper/FormHelper.php#L1063

However, BootstrapFormHelper overrides this function. The line in question that adds templateVars to the array is notably missing here:
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/950221c851dc22da89a8d85820194c89296f6670/src/View/Helper/BootstrapFormHelper.php#L403

Therefore, this does not work: http://book.cakephp.org/3.0/en/views/helpers/form.html#adding-additional-template-variables-to-templates

I can confirm that it does work correctly after adding FormHelper.php#L1063 before BootstrapFormHelper.php#L40.

id is defined twice

Hello,
I saw that almost all input() excepting select and textarea; ie text, number, tel, etc... define the id twice:

<div class="form-group tel required"><label class="col-md-2 control-label" for="phone">Téléphone du site :</label><div class="col-md-6"><input class="form-control" placeholder="Téléphone du site" required="required" maxlength="20" **id="phone"** type="tel" name="phone" **id="phone"** /></div></div>

Do you confirm?

Alain

Problem with textarea

Hello,

When I create a Form with textarea, it's the case of 'address', it doesn't fill the same horizontal space.
How to do it?

Form->create($site, ['horizontal' => true]) ?> Form->input('name'); ?> Form->input('address', ['label' => __("Adresse du site :"), 'placeholder' => __("Adresse du site")]); ?> Form->button(__('Enregistrer')) ?> Form->end() ?>

Group multiple input in the same row

Hello there,

First, thanks for releasing this Plugin.

Is is possible to group multiple input inside the same row ?
For exemple, if I want to show 2 input in the same row, I use the following code :

<div class="row">
    <?= $this->Form->input('name', [
        "label" => false,
        "type" => "text",
        'templates' => [
            'inputContainer' => '<div class="col-lg-6">{{content}}</div>'
        ],
    ]);
    ?>
    <?= $this->Form->input('surname', [
        "label" => false,
        "type" => "text",
        'templates' => [
            'inputContainer' => '<div class="col-lg-6">{{content}}</div>'
        ],]);
    ?>
</div>

Am i missing something or is the only way ?

Thanks in advance

Infinite loop since 1f69396

Hello,

The helper seems to get stuck in an infinite loop since the latest patch:
15 0.0616 4201232 call_user_func_array ( ) ../BootstrapFormHelper.php:220
16 0.0616 4201728 Bootstrap3\View\Helper\BootstrapFormHelper->date( ) ../BootstrapFormHelper.php:220
17 0.0617 4203576 Bootstrap3\View\Helper\BootstrapFormHelper->_wrapTemplates( ) ../BootstrapFormHelper.php:576
18 0.0617 4203352 call_user_func_array ( ) ../BootstrapFormHelper.php:220
19 0.0617 4203776 Bootstrap3\View\Helper\BootstrapFormHelper->date( ) ../BootstrapFormHelper.php:220
20 0.0618 4205624 Bootstrap3\View\Helper\BootstrapFormHelper->_wrapTemplates( ) ../BootstrapFormHelper.php:576
21 0.0618 4206080 call_user_func_array ( ) ../BootstrapFormHelper.php:220
22 0.0618 4206504 Bootstrap3\View\Helper\BootstrapFormHelper->date( ) ../BootstrapFormHelper.php:220

...and so on, until either xdebug reaches its nesting level or execution time runs out.

Radio button

Hello,
It seems we talk about this feature already and I think you told me this functionality should be available in the last versions but I didn't see it in your wiki page.
I tried using the cakePHP3 helper method but I cannot get it working.
Is it normal?
Is there a way to use it with your module?

The ctp code I use is:

<?= $this->Form->radio(
     'agpoiaudios.'.$ntext.'.rec_mod',
     [
          ['value' => 'sv', 'text' => __('Synthèse vocale')],
          ['value' => 'vh', 'text' => __('voix humaine (sur devis)')],
     ]
 ); ?>

The generated html code is:

<div class="radio">
    <label for="agpoiaudios-0-rec-mod-sv">
        <input type="radio" name="agpoiaudios[0][rec_mod]" value="sv" id="agpoiaudios-0-rec-mod-sv">Synthèse vocale
    </label>
</div>
<div class="radio">
    <label for="agpoiaudios-0-rec-mod-vh">
        <input type="radio" name="agpoiaudios[0][rec_mod]" value="vh" id="agpoiaudios-0-rec-mod-vh">voix humaine (sur devis)
    </label>
</div>

Do you see any reason why it doesn't work?

regards,
Alain

Add pagination support for first and last

Right now i am using following code:

<?= $this->Paginator->numbers([
       "size"=>"large",
       "prev"=>"i:chevron-left",
       "next"=>"i:chevron-right"
        ]);?>

and this generates pagination with prev next buttons. Please add support to append first/last buttons to pogaination as well.
Using next() and prev() causes generation of separate unordered lists.

Maybe i am using it wrong?

Composer require fail

Hey,

First of all thanks for the nice plugin. We are using it for https://github.com/cakemanager/cakeadmin-lightstrap.
I am trying to get composer working but get the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for cakemanager/cakeadmin-lightstrap dev-master -> satisfiable by cakemanager/cakeadmin-lightstrap[dev-master].
    - cakemanager/cakeadmin-lightstrap dev-master requires holt59/cakephp3-bootstrap3-helpers dev-master -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

So can you tell me why composer sais that your package couldn't be found?

Thanks!

Input file issue

On form template:

<?= $this->Form->file('imagem_capa') ?>

Is raising this error:

Undefined index: id [ROOT\vendor\holt59\cakephp3-bootstrap3-helpers\src\View\Helper\BootstrapFormHelper.php, line 421]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.