CakePHP span tag within input form

2.2k views Asked by At

I am trying to insert a span tag after or before an input text tag. Basically what I want in html is this:

<div class="input">
<span class="counter"></span>
<input name="whatever" class="word_count" type="text" />
</div>

I resolved by turning off the div in the formhelper, and writing everything manually, except for the input text tag. I just wanted to know if there is a way to accomplish this using the formhelper.

I read about Html->tag, I tried to put that inside the formhelper but to no avail.

Any help would be appreciated.

1

There are 1 answers

0
Nizam On BEST ANSWER

yes you can.

You may try the before/after options or wrap options. Check which one that suits your need.

CakePHP Form input Wrap

$this->Form->input('Model.field', array(
    'error' => array(
        'attributes' => array('wrap' => 'span', 'class' => 'bzzz')
    )
));

CakePHP Form Input Before/After

echo $this->Form->input('field', array(
    'before' => '--before--',
    'after' => '--after--',
    'between' => '--between---'
));

You can read more of this in cakephp book.http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html