• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Settiing error delimiters in config/form_validation.php

#1
Hi,

How to set error delimiters in config/form_validation.php file. I tried this way but it doesnot work
PHP Code:
$config = array(
 
   
    
'membership_form' => array(
 
       'error_prefix' => '<div class="has-error">',
 
       'error_suffix' => '</div>',
 
       array(
 
           'field' => 'member_name',
 
           'label' => 'Ad',
 
           'rules' => 'trim|required'
 
           ),
 
       array(
 
           'field' => 'member_surname',
 
           'label' => 'Soyad',
 
           'rules' => 'trim|required'
 
           ),
 
       array(
 
           'field' => 'member_phone',
 
           'label' => 'Kamu Telefon',
 
           'rules' => 'trim|min_length[10]|max_length[13]'
 
           ),
 
       array(
 
           'field' => 'member_email',
 
           'label' => 'Mail Adres',
 
           'rules' => 'required|valid_email|is_unique_email'
 
           ),
 
       array(
 
           'field' => 'member_password',
 
           'label' => 'Şifre',
 
           'rules' => 'trim|required|matches[member_password2]'
 
           ),
 
       array(
 
           'field' => 'member_password2',
 
           'label' => 'Şifre',
 
           'rules' => 'trim|required'
 
           ),
 
       array(
 
           'field' => 'lg_remember',
 
           'label' => 'Gizlilik Sözleşmesi',
 
           'rules' => 'required' 
 
           ) ,
 
       array(
 
           'field' => 'recaptcha_response_field',
 
           'label' => 'Güvenlik kodu',
 
           'rules' => 'required|is_valid_captcha[recaptcha_challenge_field]' 
 
           
 
       )
 
   ); 
Reply

#2
You could try this:
PHP Code:
$config = array(
 
   
    
'error_prefix' => '<div class="has-error">',
 
   'error_suffix' => '</div>',

 
   'membership_form' => array(
 
       array(
 
           'field' => 'member_name',
 
           'label' => 'Ad',
 
           'rules' => 'trim|required'
 
           ),
 
       // ...
 
       )
 
   ); 
Reply

#3
No difference, it puts error message within default delimiters
Reply

#4
No can do.

It's made to accept only validation rules, and these two settings are explicitly checked for and ignored.
Reply

#5
If they're static you can do this:

/codeigniter/application/libraries/MY_Form_validation.php:


PHP Code:
<?php if ( !defined'BASEPATH' ) ) exit( 'No direct script access allowed' );

class 
MY_Form_validation extends CI_Form_validation {
    public function 
__construct$rules = array( ) ) {
        
parent::__construct$rules );

        
$this->set_error_delimiters'<div class="has-error">''</div>' );
    }


Or you can add a config option for delimiters and pull the config values and set those.
Reply

#6
Thaks Spjones, your advice is good for me
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.