2

I am doing a form on Code Ignither 3 HMVC each time I try to save the items in the form I get validation error for three of the form fields out off four. Please see view file for my code: `">

                      <fieldset>
                        <div class="control-group">
                          <label class="control-label" for="item_title">Item Title </label>
                          <div class="controls">
                            <input type="text" class="span6" id="item_title"  value ="<?php echo $item_title; ?>">

                          </div>
                        </div>
                        <div class="control-group">
                          <label class="control-label" for="item_title">Item Price </label>
                          <div class="controls">
                            <input type="text" class="span1" id="item_price"  value ="<?php echo $item_price; ?>">
                          </div>
                        </div>
                        <div class="control-group">
                          <label class="control-label" for="was_price">Was Price <span style="color:green;">Optional</span> </label>
                          <div class="controls">
                            <input type="text" class="span1" id="was_price"  value = "<?php echo $was_price; ?>" >
                          </div>
                        </div>                  
                        <div class="control-group hidden-phone">
                          <label class="control-label" for="textarea2">Textarea WYSIWYG</label>
                          <div class="controls">
                            <textarea class="cleditor" id="textarea2" rows="3" name ="item_discription"><?php echo $item_discription;    ?></textarea>
                          </div>
                        </div>
                        <div class="form-actions">
                          <button type="submit" class="btn btn-primary" name="submit" value="Submit">Save changes</button>
                          <button type="reset" class="btn">Cancel</button>
                        </div>
                      </fieldset>
                    </form>`

please note where the variable $item_discription is placed in the textrea may be this is the reason why that field may getting the data except for the others i even tried using set_value() still get the form_vlidation error please see controller: fetch method in controller

form validation

error message

bsquad
  • 66
  • 8

1 Answers1

0

use trim in your validation rules. WYSIWYG type editors give some extra spaces in the textarea. so try to change your validation rules to,

$this->form_validation->set_rules('item_discription','Item Discription','trim|required');
Ashraful Islam
  • 895
  • 7
  • 17