Friday, August 1, 2014

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

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' => '<div class="form-group input {{type}}{{required}}">{{content}}</div>',

or create a custom widget, depending on how much customisation you want

 


On 01 Aug 2014, at 12:24, Mikaƫl Capelle <capelle...@gmail.com> 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+unsubscribe@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.

No comments: