<div class="input-group">
<span class="input-group-addon">@</span>^^^^ 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 <[email protected]>
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 <[email protected]>
>> 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->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' => '<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 <[email protected]>
>>>>>>>> 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/cake
>>>>>>>> php-bootstrap3-helpers/blob/master/View/Helper/BootstrapFo
>>>>>>>> rmHelper.php
>>>>>>>> > • CakePHP 3 - https://github.com/Holt59/cake
>>>>>>>> php3-bootstrap3-helpers/blob/master/View/Helper/BootstrapFo
>>>>>>>> rmHelper.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 [email protected].
>>>>>>>> > To post to this group, send email to [email protected].
>>>>>>>> > 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/cake-php.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> =============================================================
>> The Conference Schedule Creator : http://shdlr.com
>>
>> PHP for E-Biz : http://sanisoft.com
>> =============================================================
>>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>
--
=============================================================
The Conference Schedule Creator : http://shdlr.com
PHP for E-Biz : http://sanisoft.com
=============================================================
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.