Re: CakePHP 3.0 Plugin - Where to put a « global » function for multiple helpers

2015-07-27 Thread Mikaël Capelle
Thanks! Exactly what I was looking for.

On Monday, July 27, 2015 at 2:29:31 PM UTC+2, Florian Krämer wrote:
>
> Then use a trait <http://php.net/manual/en/language.oop5.traits.php>.
>
> On Monday, July 27, 2015 at 11:32:54 AM UTC+2, Mikaël Capelle wrote:
>>
>> I cannot do that without multiple inheritance (which, as far as I know, 
>> does not exist in php) because as I stated in my post, all my helpers does 
>> not inherit a standard CakePHP helpers, for instance I have:
>>
>> class MyHTMLHelper extends HTMLHelper { ... }
>> class MyFormHelper extends FormHelper { ... }
>> class MyPagiHelper extends PaginatorHelper { ... }
>>
>> On Monday, July 27, 2015 at 11:28:00 AM UTC+2, Florian Krämer wrote:
>>>
>>> Simple OOP?
>>>
>>> MySpecialHelper extends MyBaseHelper {...}
>>> MyOtherSpecialHelper extends MyBaseHelper {...}
>>>
>>>
>>>
>>> And MyBaseHelper implementds addClass().
>>>
>>> On Friday, July 24, 2015 at 10:23:43 AM UTC+2, Mikaël Capelle wrote:
>>>>
>>>> Hi everyone,
>>>>
>>>> I am writing a CakePHP 3.0 plugins, and I have multiple helpers 
>>>> (inheriting from either HTMLHelper, FormHelper, PaginatorHelper, 
>>>> etc.). In each of these new helpers, I have a function *addClass* 
>>>> (copy/paste from helper to helper... ).
>>>>
>>>> I don't really like having duplicated code (5 times... ), but I don't 
>>>> know where I should put this function to follow CakePHP 3.0 plugin 
>>>> conventions, knowing that the plugin consists of only helpers?
>>>>
>>>> Thanks.
>>>>
>>>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3.0 Plugin - Where to put a « global » function for multiple helpers

2015-07-27 Thread Mikaël Capelle
I cannot do that without multiple inheritance (which, as far as I know, 
does not exist in php) because as I stated in my post, all my helpers does 
not inherit a standard CakePHP helpers, for instance I have:

class MyHTMLHelper extends HTMLHelper { ... }
class MyFormHelper extends FormHelper { ... }
class MyPagiHelper extends PaginatorHelper { ... }

On Monday, July 27, 2015 at 11:28:00 AM UTC+2, Florian Krämer wrote:
>
> Simple OOP?
>
> MySpecialHelper extends MyBaseHelper {...}
> MyOtherSpecialHelper extends MyBaseHelper {...}
>
>
>
> And MyBaseHelper implementds addClass().
>
> On Friday, July 24, 2015 at 10:23:43 AM UTC+2, Mikaël Capelle wrote:
>>
>> Hi everyone,
>>
>> I am writing a CakePHP 3.0 plugins, and I have multiple helpers 
>> (inheriting from either HTMLHelper, FormHelper, PaginatorHelper, etc.). 
>> In each of these new helpers, I have a function *addClass* (copy/paste 
>> from helper to helper... ).
>>
>> I don't really like having duplicated code (5 times... ), but I don't 
>> know where I should put this function to follow CakePHP 3.0 plugin 
>> conventions, knowing that the plugin consists of only helpers?
>>
>> Thanks.
>>
>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3.0 Plugin - Where to put a « global » function for multiple helpers

2015-07-24 Thread Mikaël Capelle
Hi everyone,

I am writing a CakePHP 3.0 plugins, and I have multiple helpers (inheriting 
from either HTMLHelper, FormHelper, PaginatorHelper, etc.). In each of 
these new helpers, I have a function *addClass* (copy/paste from helper to 
helper... ).

I don't really like having duplicated code (5 times... ), but I don't know 
where I should put this function to follow CakePHP 3.0 plugin conventions, 
knowing that the plugin consists of only helpers?

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3.0 - Correct way to append / prepend HTML on FormHelper

2014-08-04 Thread Mikaël Capelle
Thanks for you answer, I understand your point of view.

Unfortunately the 'input' method does not generate only the HTML input tag 
(even when not using a custom helper):

$this->Form->input('mail') ;


  Mail
  


It is almost like the default CakePHP helper, I just changed the div class 
from 'input' to 'form-group'. So, now the problem with 'prepend' is that I 
need to insert HTML inside the HTML generated by the 'input' method:


  Mail
  
  
  


On Monday, August 4, 2014 1:07:16 PM UTC+2, Dr. Tarique Sani wrote:

> 
>   @ This part of the input group 
> is NOT a part of the form element thus as a best compromise I would put it in 
> a separate helper method with options - so something like
>
>
> $this->Form->inputGroup([class=>'input-group-addon', 'text'=>'@']);
>
> $this->Form->input('field',[moreoptions]);
>
>
> but then IMHO it is plain abuse of CPU cycles
>
>
> T
>
>
>
>
> On Mon, Aug 4, 2014 at 3:06 PM, Mikaël Capelle  > wrote:
>
>> How would you do that?
>>
>> I can't do this:
>>
>> echo $htmlBefore.$this->Form->input().$htmlAfter ;
>>
>> because I need to include it inside the generated HTML. Of course, I 
>> could create the whole HTML outside the helper and use the "direct" method 
>> ('text' for example) to get only the input tag, but it would be more 
>> complicated and I would lose every advantage of using a custom helper.
>>
>> Actually, this is a plugin, so I just want it to be easy to use, even if 
>> it's not easy to write (well, my code is currently working so it is not 
>> that hard). I think it's easier to write:
>>
>> echo $this->Form->input('field', ['prepend' => '@']) ;
>>
>> than to write the whole bootstrap HTML.
>>
>>
>> On Monday, August 4, 2014 8:57:54 AM UTC+2, Dr. Tarique Sani wrote:
>>
>>> If I were to do it I would leave the HTML which is before and after the 
>>> input tag out of the FormHelper  - Keep it simple...
>>>
>>> T
>>>
>>>
>>>  
>>>
>>> On Fri, Aug 1, 2014 at 8:25 PM, Mikaël Capelle  
>>> wrote:
>>>
>>>> Thanks for the link! Unfortunately it doesn't help since it does not 
>>>> allow user to create bootstrap 'input-group', it is only template for 
>>>> default input, which I've already done even if it's look better written 
>>>> this way.
>>>>
>>>>
>>>> On Friday, August 1, 2014 4:49:42 PM UTC+2, José Lorenzo wrote:
>>>>>
>>>>> Look at this project for inspiration:
>>>>>
>>>>> https://github.com/commercial-hippie/chocolate/blob/master/s
>>>>> rc/View/Helper/BootstrapFormHelper.php
>>>>>
>>>>> On Friday, August 1, 2014 2:31:44 PM UTC+2, Mikaël Capelle wrote:
>>>>>>
>>>>>> I think my question was not clear actually...
>>>>>>
>>>>>> What I'm doing is inheriting standard CakePHP FormHelper to generate 
>>>>>> HTML form with bootstrap templates. It's currently working well, but in 
>>>>>> the 
>>>>>> 'input' method overload, I'm doing a temporary change to the 'input' 
>>>>>> template as shown in my first post.
>>>>>>
>>>>>> My question is: Is that a 'good' way of doing what I want? I mean, 
>>>>>> using temporary template changes. 
>>>>>>
>>>>>> I don't want people to have to change the template manually when 
>>>>>> calling the 'input' method, it should be transparent for users.
>>>>>>
>>>>>> Thanks for your answer,
>>>>>>
>>>>>> On Friday, August 1, 2014 2:21:34 PM UTC+2, José Lorenzo wrote:
>>>>>>>
>>>>>>> You can make temporary changes to the templates both with 
>>>>>>> Form->create() and Form->input()
>>>>>>>
>>>>>>> $this->From-input('foo', ['templates' => ['inputContainer' => 
>>>>>>> $template]]); 
>>>>>>>
>>>>>>> An alternative is not using input(); but just build the html 
>>>>>>> yourself in the template and call $this->Form-&

Re: CakePHP 3.0 - Correct way to append / prepend HTML on FormHelper

2014-08-04 Thread Mikaël Capelle
How would you do that?

I can't do this:

echo $htmlBefore.$this->Form->input().$htmlAfter ;

because I need to include it inside the generated HTML. Of course, I could 
create the whole HTML outside the helper and use the "direct" method 
('text' for example) to get only the input tag, but it would be more 
complicated and I would lose every advantage of using a custom helper.

Actually, this is a plugin, so I just want it to be easy to use, even if 
it's not easy to write (well, my code is currently working so it is not 
that hard). I think it's easier to write:

echo $this->Form->input('field', ['prepend' => '@']) ;

than to write the whole bootstrap HTML.

On Monday, August 4, 2014 8:57:54 AM UTC+2, Dr. Tarique Sani wrote:
>
> If I were to do it I would leave the HTML which is before and after the 
> input tag out of the FormHelper  - Keep it simple...
>
> T
>
>
>
>
> On Fri, Aug 1, 2014 at 8:25 PM, Mikaël Capelle  > wrote:
>
>> Thanks for the link! Unfortunately it doesn't help since it does not 
>> allow user to create bootstrap 'input-group', it is only template for 
>> default input, which I've already done even if it's look better written 
>> this way.
>>
>>
>> On Friday, August 1, 2014 4:49:42 PM UTC+2, José Lorenzo wrote:
>>>
>>> Look at this project for inspiration:
>>>
>>> https://github.com/commercial-hippie/chocolate/blob/master/
>>> src/View/Helper/BootstrapFormHelper.php
>>>
>>> On Friday, August 1, 2014 2:31:44 PM UTC+2, Mikaël Capelle wrote:
>>>>
>>>> I think my question was not clear actually...
>>>>
>>>> What I'm doing is inheriting standard CakePHP FormHelper to generate 
>>>> HTML form with bootstrap templates. It's currently working well, but in 
>>>> the 
>>>> 'input' method overload, I'm doing a temporary change to the 'input' 
>>>> template as shown in my first post.
>>>>
>>>> My question is: Is that a 'good' way of doing what I want? I mean, 
>>>> using temporary template changes. 
>>>>
>>>> I don't want people to have to change the template manually when 
>>>> calling the 'input' method, it should be transparent for users.
>>>>
>>>> Thanks for your answer,
>>>>
>>>> On Friday, August 1, 2014 2:21:34 PM UTC+2, José Lorenzo wrote:
>>>>>
>>>>> You can make temporary changes to the templates both with 
>>>>> Form->create() and Form->input()
>>>>>
>>>>> $this->From-input('foo', ['templates' => ['inputContainer' => 
>>>>> $template]]); 
>>>>>
>>>>> An alternative is not using input(); but just build the html yourself 
>>>>> in the template and call $this->Form->text('foo') , for example
>>>>>
>>>>> On Friday, August 1, 2014 1:51:48 PM UTC+2, Mikaël Capelle wrote:
>>>>>>
>>>>>> Thanks for your answer!
>>>>>>
>>>>>> The problem is still the same with 'inputContainer', I need to make a 
>>>>>> temporary update if I want to prepend / append something.
>>>>>>
>>>>>> I will look at custom widget but I am not sure it's match what I 
>>>>>> want... The prepend / append options should be available with most type 
>>>>>> of 
>>>>>> input, it's not really a widget itself.
>>>>>>
>>>>>> On Friday, August 1, 2014 1:37:54 PM UTC+2, Thomas von Hassel wrote:
>>>>>>>
>>>>>>> use the `inputContainer` template to wrap the content like this: 
>>>>>>>
>>>>>>> 'inputContainer' => '{{content}}’, 
>>>>>>>
>>>>>>> or create a custom widget, depending on how much customisation you 
>>>>>>> want 
>>>>>>>
>>>>>>>   
>>>>>>>
>>>>>>>
>>>>>>> On 01 Aug 2014, at 12:24, Mikaël Capelle  
>>>>>>> wrote: 
>>>>>>>
>>>>>>> > Hi everyone, 
>>>>>>> > 
>>>>>>> > I am porting my CakePHP 2.0 helpers to CakePHP 3.0 and I am facing 
>>>>>>> some troubles wit

Re: CakePHP 3.0 - Correct way to append / prepend HTML on FormHelper

2014-08-01 Thread Mikaël Capelle
Thanks for the link! Unfortunately it doesn't help since it does not allow 
user to create bootstrap 'input-group', it is only template for default 
input, which I've already done even if it's look better written this way.

On Friday, August 1, 2014 4:49:42 PM UTC+2, José Lorenzo wrote:
>
> Look at this project for inspiration:
>
>
> https://github.com/commercial-hippie/chocolate/blob/master/src/View/Helper/BootstrapFormHelper.php
>
> On Friday, August 1, 2014 2:31:44 PM UTC+2, Mikaël Capelle wrote:
>>
>> I think my question was not clear actually...
>>
>> What I'm doing is inheriting standard CakePHP FormHelper to generate HTML 
>> form with bootstrap templates. It's currently working well, but in the 
>> 'input' method overload, I'm doing a temporary change to the 'input' 
>> template as shown in my first post.
>>
>> My question is: Is that a 'good' way of doing what I want? I mean, using 
>> temporary template changes. 
>>
>> I don't want people to have to change the template manually when calling 
>> the 'input' method, it should be transparent for users.
>>
>> Thanks for your answer,
>>
>> On Friday, August 1, 2014 2:21:34 PM UTC+2, José Lorenzo wrote:
>>>
>>> You can make temporary changes to the templates both with Form->create() 
>>> and Form->input()
>>>
>>> $this->From-input('foo', ['templates' => ['inputContainer' => 
>>> $template]]); 
>>>
>>> An alternative is not using input(); but just build the html yourself in 
>>> the template and call $this->Form->text('foo') , for example
>>>
>>> On Friday, August 1, 2014 1:51:48 PM UTC+2, Mikaël Capelle wrote:
>>>>
>>>> Thanks for your answer!
>>>>
>>>> The problem is still the same with 'inputContainer', I need to make a 
>>>> temporary update if I want to prepend / append something.
>>>>
>>>> I will look at custom widget but I am not sure it's match what I 
>>>> want... The prepend / append options should be available with most type of 
>>>> input, it's not really a widget itself.
>>>>
>>>> On Friday, August 1, 2014 1:37:54 PM UTC+2, Thomas von Hassel wrote:
>>>>>
>>>>> use the `inputContainer` template to wrap the content like this: 
>>>>>
>>>>> 'inputContainer' => '{{content}}’, 
>>>>>
>>>>> or create a custom widget, depending on how much customisation you 
>>>>> want 
>>>>>
>>>>>   
>>>>>
>>>>>
>>>>> On 01 Aug 2014, at 12:24, Mikaël Capelle  
>>>>> wrote: 
>>>>>
>>>>> > Hi everyone, 
>>>>> > 
>>>>> > I am porting my CakePHP 2.0 helpers to CakePHP 3.0 and I am facing 
>>>>> some troubles with my custom FormHelper. The helpers are made to be used 
>>>>> with bootstrap, the two form helpers can be found here: 
>>>>> > • CakePHP 2 - 
>>>>> https://github.com/Holt59/cakephp-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php
>>>>>  
>>>>> > • CakePHP 3 - 
>>>>> https://github.com/Holt59/cakephp3-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php
>>>>>  
>>>>> > In the BootstrapFormHelper::input method, I have a 'prepend' and 
>>>>> 'append' options which are used to create bootstrap input groups. With 
>>>>> the 
>>>>> 2.0 version, I used the 'before' and 'after' options to create such 
>>>>> groups 
>>>>> but these options are not available anymore with CakePHP 3.0 so what I'm 
>>>>> doing is a temporary template change: 
>>>>> > 
>>>>> > $oldTemplate = $this->templates('input') ; 
>>>>> > if ($options['prepend']) { 
>>>>> > $this->templates([ 
>>>>> > 'input' => /* ... */ 
>>>>> > ]) ; 
>>>>> > } 
>>>>> > $res = parent::input(/* ... */) ; 
>>>>> > $this->templates([ 
>>>>> > 'input' => $oldTemplate 
>>>>> > ]) ; 
>>>>> > return $res ; 
>>>>> > 
>>>>> > Is there a better way to do such thing with CakePHP 3.0? 
>>>>> > 
>>>>> > Thanks, 
>>>>> > 
>>>>> > -- 
>>>>> > Like Us on FaceBook https://www.facebook.com/CakePHP 
>>>>> > Find us on Twitter http://twitter.com/CakePHP 
>>>>> > 
>>>>> > --- 
>>>>> > You received this message because you are subscribed to the Google 
>>>>> Groups "CakePHP" group. 
>>>>> > To unsubscribe from this group and stop receiving emails from it, 
>>>>> send an email to cake-php+u...@googlegroups.com. 
>>>>> > To post to this group, send email to cake...@googlegroups.com. 
>>>>> > Visit this group at http://groups.google.com/group/cake-php. 
>>>>> > For more options, visit https://groups.google.com/d/optout. 
>>>>>
>>>>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3.0 - Correct way to append / prepend HTML on FormHelper

2014-08-01 Thread Mikaël Capelle
I think my question was not clear actually...

What I'm doing is inheriting standard CakePHP FormHelper to generate HTML 
form with bootstrap templates. It's currently working well, but in the 
'input' method overload, I'm doing a temporary change to the 'input' 
template as shown in my first post.

My question is: Is that a 'good' way of doing what I want? I mean, using 
temporary template changes. 

I don't want people to have to change the template manually when calling 
the 'input' method, it should be transparent for users.

Thanks for your answer,

On Friday, August 1, 2014 2:21:34 PM UTC+2, José Lorenzo wrote:
>
> You can make temporary changes to the templates both with Form->create() 
> and Form->input()
>
> $this->From-input('foo', ['templates' => ['inputContainer' => 
> $template]]); 
>
> An alternative is not using input(); but just build the html yourself in 
> the template and call $this->Form->text('foo') , for example
>
> On Friday, August 1, 2014 1:51:48 PM UTC+2, Mikaël Capelle wrote:
>>
>> Thanks for your answer!
>>
>> The problem is still the same with 'inputContainer', I need to make a 
>> temporary update if I want to prepend / append something.
>>
>> I will look at custom widget but I am not sure it's match what I want... 
>> The prepend / append options should be available with most type of input, 
>> it's not really a widget itself.
>>
>> On Friday, August 1, 2014 1:37:54 PM UTC+2, Thomas von Hassel wrote:
>>>
>>> use the `inputContainer` template to wrap the content like this: 
>>>
>>> 'inputContainer' => '{{content}}’, 
>>>
>>> or create a custom widget, depending on how much customisation you want 
>>>
>>>   
>>>
>>>
>>> On 01 Aug 2014, at 12:24, Mikaël Capelle  wrote: 
>>>
>>> > Hi everyone, 
>>> > 
>>> > I am porting my CakePHP 2.0 helpers to CakePHP 3.0 and I am facing 
>>> some troubles with my custom FormHelper. The helpers are made to be used 
>>> with bootstrap, the two form helpers can be found here: 
>>> > • CakePHP 2 - 
>>> https://github.com/Holt59/cakephp-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php
>>>  
>>> > • CakePHP 3 - 
>>> https://github.com/Holt59/cakephp3-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php
>>>  
>>> > In the BootstrapFormHelper::input method, I have a 'prepend' and 
>>> 'append' options which are used to create bootstrap input groups. With the 
>>> 2.0 version, I used the 'before' and 'after' options to create such groups 
>>> but these options are not available anymore with CakePHP 3.0 so what I'm 
>>> doing is a temporary template change: 
>>> > 
>>> > $oldTemplate = $this->templates('input') ; 
>>> > if ($options['prepend']) { 
>>> > $this->templates([ 
>>> > 'input' => /* ... */ 
>>> > ]) ; 
>>> > } 
>>> > $res = parent::input(/* ... */) ; 
>>> > $this->templates([ 
>>> > 'input' => $oldTemplate 
>>> > ]) ; 
>>> > return $res ; 
>>> > 
>>> > Is there a better way to do such thing with CakePHP 3.0? 
>>> > 
>>> > Thanks, 
>>> > 
>>> > -- 
>>> > Like Us on FaceBook https://www.facebook.com/CakePHP 
>>> > Find us on Twitter http://twitter.com/CakePHP 
>>> > 
>>> > --- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups "CakePHP" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to cake-php+u...@googlegroups.com. 
>>> > To post to this group, send email to cake...@googlegroups.com. 
>>> > Visit this group at http://groups.google.com/group/cake-php. 
>>> > For more options, visit https://groups.google.com/d/optout. 
>>>
>>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3.0 - Correct way to append / prepend HTML on FormHelper

2014-08-01 Thread Mikaël Capelle
Thanks for your answer!

The problem is still the same with 'inputContainer', I need to make a 
temporary update if I want to prepend / append something.

I will look at custom widget but I am not sure it's match what I want... 
The prepend / append options should be available with most type of input, 
it's not really a widget itself.

On Friday, August 1, 2014 1:37:54 PM UTC+2, Thomas von Hassel wrote:
>
> use the `inputContainer` template to wrap the content like this: 
>
> 'inputContainer' => '{{content}}’, 
>
> or create a custom widget, depending on how much customisation you want 
>
>   
>
>
> On 01 Aug 2014, at 12:24, Mikaël Capelle  > wrote: 
>
> > Hi everyone, 
> > 
> > I am porting my CakePHP 2.0 helpers to CakePHP 3.0 and I am facing some 
> troubles with my custom FormHelper. The helpers are made to be used with 
> bootstrap, the two form helpers can be found here: 
> > • CakePHP 2 - 
> https://github.com/Holt59/cakephp-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php
>  
> > • CakePHP 3 - 
> https://github.com/Holt59/cakephp3-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php
>  
> > In the BootstrapFormHelper::input method, I have a 'prepend' and 
> 'append' options which are used to create bootstrap input groups. With the 
> 2.0 version, I used the 'before' and 'after' options to create such groups 
> but these options are not available anymore with CakePHP 3.0 so what I'm 
> doing is a temporary template change: 
> > 
> > $oldTemplate = $this->templates('input') ; 
> > if ($options['prepend']) { 
> > $this->templates([ 
> > 'input' => /* ... */ 
> > ]) ; 
> > } 
> > $res = parent::input(/* ... */) ; 
> > $this->templates([ 
> > 'input' => $oldTemplate 
> > ]) ; 
> > return $res ; 
> > 
> > Is there a better way to do such thing with CakePHP 3.0? 
> > 
> > Thanks, 
> > 
> > -- 
> > Like Us on FaceBook https://www.facebook.com/CakePHP 
> > Find us on Twitter http://twitter.com/CakePHP 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups "CakePHP" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to cake-php+u...@googlegroups.com . 
> > To post to this group, send email to cake...@googlegroups.com 
> . 
> > Visit this group at http://groups.google.com/group/cake-php. 
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3.0 - Correct way to append / prepend HTML on FormHelper

2014-08-01 Thread Mikaël Capelle
Hi everyone,

I am porting my CakePHP 2.0 helpers to CakePHP 3.0 and I am facing some 
troubles with my custom FormHelper. The helpers are made to be used with 
bootstrap, the two form helpers can be found here:

   - CakePHP 2 - 
   
https://github.com/Holt59/cakephp-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php
   - CakePHP 3 - 
   
https://github.com/Holt59/cakephp3-bootstrap3-helpers/blob/master/View/Helper/BootstrapFormHelper.php

In the BootstrapFormHelper::input method, I have a 'prepend' and 'append' 
options which are used to create bootstrap input groups 
. With the 2.0 version, I 
used the 'before' and 'after' options to create such groups but these 
options are not available anymore with CakePHP 3.0 so what I'm doing is a 
temporary template change:

$oldTemplate = $this->templates('input') ;
if ($options['prepend']) {
$this->templates([
'input' => /* ... */
]) ;
}
$res = parent::input(/* ... */) ;
$this->templates([
'input' => $oldTemplate
]) ;
return $res ;

Is there a better way to do such thing with CakePHP 3.0?

Thanks,

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 3.0 Validation ?

2014-07-28 Thread Mikaël Capelle
I'm not in DevoirsController. 

Thanks to your questions, I found my mistake, I named the file 
DevoirsTable.ctp instead of DevoirsTable.php... Stupid copy/paste mistake, 
thanks you for pointing me to this!

On Monday, July 28, 2014 10:54:33 PM UTC+2, José Lorenzo wrote:
>
> A few questions:
>
> - Where did you put DevoirsTable ?
> - How did you name the DevoirsTable file?
> - What namespace did you use in that file?
> - Can you verify that file is being included?
>
> And a small correction, This is not needed in a DevoirsController:
>
> $this->Devoirs = TableRegistry::get('Devoirs');
>
>
> On Monday, July 28, 2014 10:20:06 PM UTC+2, Mikaël Capelle wrote:
>>
>> Hi everyone,
>>
>> I'm trying to build a new CakePHP 3 application but I didn't manage to 
>> get the data validation working... I followed the CakePHP 3.0 book, and 
>> particulary this page 
>> http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html 
>> but it didn't help.
>>
>> Currently, my Table is as follow:
>>
>> class DevoirsTable extends Table {
>>  
>> public function initialize(array $config) {
>>  
>> }
>> 
>> public function validationDefault (Validator $validator) {
>> debug('TEST HERE') ;
>> $validator->notEmpty('pseudo', 'Oh my god!');
>> return $validator;
>> } 
>>  }
>>
>>
>> And my controller:
>>
>> $this->Devoirs = TableRegistry::get('Devoirs') ;
>> $devoir = $this->Devoirs->find()->first() ;
>> if ($this->request->is(['post', 'put'])) {
>> $this->Devoirs->patchEntity($devoir, $this->request->data) ;
>> $this->set('saved', $this->Devoirs->save($devoir, ['validate' => 
>> true])) ;
>> }
>>
>>
>> This is only a test action, the row is correctly updated in my database 
>> but the 'TEST HERE' string never showed up... I don't understand how the 
>> new validation system works, maybe someone can help me?
>>
>> Thanks,
>>
>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3.0 Validation ?

2014-07-28 Thread Mikaël Capelle
Hi everyone,

I'm trying to build a new CakePHP 3 application but I didn't manage to get 
the data validation working... I followed the CakePHP 3.0 book, and 
particulary this 
page http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html 
but it didn't help.

Currently, my Table is as follow:

class DevoirsTable extends Table {
 
public function initialize(array $config) {
 
}

public function validationDefault (Validator $validator) {
debug('TEST HERE') ;
$validator->notEmpty('pseudo', 'Oh my god!');
return $validator;
} 
 }


And my controller:

$this->Devoirs = TableRegistry::get('Devoirs') ;
$devoir = $this->Devoirs->find()->first() ;
if ($this->request->is(['post', 'put'])) {
$this->Devoirs->patchEntity($devoir, $this->request->data) ;
$this->set('saved', $this->Devoirs->save($devoir, ['validate' => 
true])) ;
}


This is only a test action, the row is correctly updated in my database but 
the 'TEST HERE' string never showed up... I don't understand how the new 
validation system works, maybe someone can help me?

Thanks,

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 3.0 - Custom helpers not working

2014-06-11 Thread Mikaël Capelle
Hi everyone,

I'm trying to update my helpers to CakePHP 3.0 but each time I try to load 
them I get the following error : 

Error: *Html* could not be found.
> Error: Create the class *Html* below in file: App\View\Helper\Html.php


My AppController looks like : 

public $helpers = [
> 'Html' => [
> 'className' => 'MyHtml'
> ]
> ];


And App/View/Helper/MyHtmlHelper.php

use Cake\View\Helper\HtmlHelper;
> class MyHtmlHelper extends HtmlHelper { /* ... */ } ;


I followed the instruction right here 
http://book.cakephp.org/3.0/en/views/helpers.html, even if I didn't see any 
change since CakePHP 2.3 (except the namespace).

Thanks,

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.