Jeff Davidson
Jeff Davidson

Reputation: 1929

Validating Text Areas

All my other form elements validate BUT my text area. Thoughts onto maybe why with the following code?

<?php $attributes = array('cols' => '30', 'rows' => '5', 'id' => 'article', 'class' => 'required') ?>
 <div>
     <?php echo form_textarea('article', '', $attributes); ?>  
 </div>

EDIT: I'm using the jQuery validation class.

<div class="section _100">
<label for="article">Article</label>   
    <div>
        <textarea name="article" cols="40" rows="10" Array></textarea>  
    </div>
</div>

SO now I"m wondering why its showing that Array like that when it should be finishing putting the attributes like the class part.

Upvotes: 0

Views: 631

Answers (2)

Colin Brock
Colin Brock

Reputation: 21575

Per the Form_helper documentation, you can generate a textarea by passing a name and attribute value as two arguments or by passing all your attributes as an array as a single argument.

Notice in your code, you have a 3rd argument. That is reserved for additional data, like JavaScript. It's just appended within the textarea tag as a string - which is why you're seeing Array.

Create your textarea like this, but including your name in the $attributes array:

$attributes = array(
    'name' => 'article', 
    'cols' => '30',
    'rows' => '5', 
    'id' => 'article', 
    'class' => 'required'
);

echo form_textarea($attributes); 

Upvotes: 3

Kosta
Kosta

Reputation: 1867

When you pass array of attributes, then it should be the only form_textarea function. Try this:

<?php $attributes = array('name' => 'article', 'cols' => '30', 'rows' => '5', 'id' => 'article', 'class' => 'required') ?>
<div>
    <?php echo form_textarea($attributes); ?>  
</div>

Upvotes: 1

Related Questions