[eluser]Ashes-to-Ashes[/eluser]
In fact, I just verified that YES you can return a value instead of true or false. It is working on one of my callbacks but not the other.
Non working function
Code:
public function _tag_number_check($str)
{
echo '<br>CHECKING TAG NUMBER WITH HIDDEN TAG NUMBER CHECK IN MAIN CONTROLLER';
print_r ($_POST);
if ($str == '') { $str = $_POST['tag']; }
if ($str == '') {
echo 'String is Blank';
$this->form_validation->set_message('_tag_number_check', '%s is blank.');
return false;
} // if blank, but required, then handled in form area
$this->load->model ('tags_model');
// 9/5/2012 Jonathan seems this is already loaded if check being called
//$this->load->library ('form_validation');
if (!is_numeric($str))
{
echo "'$str' not numeric";
$this->show->line (' Tag number not numeric, attempting look up as a string of words or words seperated by "&" symbol ');
$query = $this->tags_model->select_query_from_search ($str);
if ($query)
{
echo "Query returned results <br>";
if ($query->num_rows > 1)
{
$this->form_validation->set_message('_tag_number_check', 'More than one tag number found for search');
foreach ($query->result() as $row)
{
$this->show->line ($row->number. ' -- '.$row->label);
}
return FALSE;
}
elseif ($query->num_rows == 1)
{
echo "Only one match found. Tag number from this match.<br>";
$row = $query->row();
echo "Number is: $row->number<br>";
return $row->number;
// TASK: Figure out why this value is dropped somewhere between current and form using data
// Currently have to rewrite the data in three places instead of just here
}
else
{
$this->form_validation->set_message('tag_number_check', 'No tags found using text search ');
return FALSE;
}
} // query true
else { $this->form_validation->set_message ('tag_number_check', 'No results for that search');
}
} // is numeric
else
{
if ($this->tags_model->select_tag ($str))
{
return true;
}
else
{
$this->form_validation->set_message ('tag_number_check', 'No results for that tag number');
return FALSE;
}
}
return false;
// TASK: look for valid tag number
} // function tag_number_check
Working callback
Code:
public function _account_number_check($str)
{
if ($str == ``) {
return true;
} // if blank, but required, then handled in form area
echo 'CHECKING ACCOUNT NUMBER HIDDEN FUNCTION MAIN CONTROLLER';
$this->load->model ('accounts_model');
$this->load->library ('form_validation');
if (!is_numeric($str))
{
$this->show->line (' Account number not numeric, attempting look up as a string ');
$query = $this->accounts_model->select_query_from_search ($str);
if (!empty ($query))
{
if ($query->num_rows > 1)
{
$this->form_validation->set_message('_account_number_check', 'More than one account found for search');
foreach ($query->result() as $row)
{
$this->show->line ($row->number. ' -- '.$row->name);
}
return FALSE;
}
elseif ($query->num_rows === 1)
{
$row = $query->row();
return $row->number;
}
else
{
$this->form_validation->set_message('account_number_check', 'No accounts found using text search (use word & word & word .....)');
$this->show->link ('Right click on this link, and open in new tab to create account
then close that tab when done, and re-try this form',
array ('account', 'action', 'new'));
// TASK: pop-up account creation with pick root...
// When window closes insert that number in the field, and use
// JAVA to show name?
return FALSE;
}
}
return false;
}
return true; // TASK: check for bad account number
}
I am guessing that my particular error is is somewhere else, but I don't know where or how.