Skip to main content

Unable to access an error message corresponding to your field name.

May 6, 2011 by tedz.tm

tedz.tm's picture

Saya termasuk newbie di CI ini ... ada masalahah keluar error Unable to access an error message corresponding to your field name.
pemanggilan form validasi :
$this->form_validation->set_rules('loc_skno','NO SK', 'required|callback_valid_loc_skno');

........................
function valid_loc_skno($loc_skno)
{
if ($this->Acrodoc_model->valid_loc_skno($loc_skno) == FALSE)

{
return FALSE;
}
else
{
$this->form_validation->set_message('valid_loc_skno', " '$loc_skno' sudah ada");
return TRUE;
}
}

ada yang salahkah dari script tersebut

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Ini pemaggilan 'own

May 6, 2011 by joedy, 21 weeks 5 days ago
Comment: 8117

joedy's picture

Ini pemaggilan 'own validation function':
$this->form_validation->set_rules('loc_skno','NO SK', 'required|callback__valid_loc_skno');

pemanggilannnya sebaiknya menggunakan fungsi private supaya tidak bs d akses dr URL.

function _valid_loc_skno($str){
if ($this->Acrodoc_model->valid_loc_skno($loc_skno) === FALSE){ //sama dengan 3x u/ memastikan nilanya hanya berupa boolean lihat dsini: http://codeigniter.com/user_guide/general/styleguide.html#comparing_retu...
$this->form_validation->set_message('_valid_loc_skno', 'Field %s sudah ada');
return FALSE;
}
return TRUE;
}

happy codding ;)

Thx Bro

May 6, 2011 by tedz.tm, 21 weeks 5 days ago
Comment: 8120

tedz.tm's picture

coding berjalan dengan lancar tanpa error, thx atas pencerahannnya...

Premium Drupal Themes by Adaptivethemes