Welcome Guest, Not a member yet? Register   Sign In
MY_Form_validation method not called on empty string?
#1

[eluser]Unknown[/eluser]
I have extended the form validation to include some extra methods. One of them needs to check if 2 inputs are not empty together, however the method never gets called if the input is empty:

application/libraries/MY_Form_validation.php:

Code:
class MY_Form_validation extends CI_Form_validation {

public function __construct($config = array())
{
  log_message('debug', 'MY_Form_validation loaded<<<');
  parent::__construct($config);
}

public function lat_longs($str)
{
  echo "lat_longs called";
  var_dump($this->CI->input->post('map_lat'));
  var_dump($str);
  return FALSE;
}

application/language/english/form_validation_lang.php:

Code:
$lang['lat_longs'] = "Some error message here.";

application/config/form_valiation.php

Code:
'venues' => array(
  array(
   'field' => 'map_lat',
   'label' => 'Latitude',
   'rules' => 'trim|htmlspecialchars|lat_longs|numeric|xss_clean'
  ),
  array(
   'field' => 'map_lng',
   'label' => 'Longitude',
   'rules' => 'trim|htmlspecialchars|lat_longs|numeric|xss_clean'
  )
),

in the view file:
Code:
&lt;?php echo form_error('map_lat'); ?&gt;

The lat_longs() method never seems to get called if the $_POST['map_lat'] or $_POST['map_lng'] is empty...

Any ideas?


Messages In This Thread
MY_Form_validation method not called on empty string? - by El Forum - 01-20-2013, 07:46 AM
MY_Form_validation method not called on empty string? - by El Forum - 01-20-2013, 03:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB