フォームには、数値がis_availableかどうかをチェックするコールバック関数があります。TRUEを返すと、エラーメッセージが表示されます。
コールバックは機能していますが、別のファイルで指定されたコンテンツの代わりに:lang:shortcodes.not_uniqueが表示されます。
私は何が悪いのか理解できず、ユーザーガイドでそれを見つけられませんでした。
ご協力ありがとうございました。
public function __construct()
{
parent::__construct();
// Load all the required classes
$this->load->model('shortcodes_m');
$this->load->library('form_validation');
$this->lang->load('shortcodes');
// Set the validation rules
$this->item_validation_rules = array(
array(
'field' => 'number',
'label' => 'lang:shortcodes.number',
'rules' => 'trim|max_length[100]|required|numeric'
),
array(
'field' => 'name',
'label' => 'lang:shortcodes.name',
'rules' => 'trim|max_length[100]|required|callback_shortcodes_check'
)
);
}
public function shortcodes_check($str)
{
if($this->shortcodes_m->is_available($str) == TRUE)
{
$this->form_validation->set_message('shortcodes_check','lang:shortcodes.not_unique');
return FALSE;
}
else
{
return TRUE;
}
}