0

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 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.