Part of the EllisLab Network
   
4 of 4
4
CI 2.1.0 form validation external callbacks via the newly available param
Posted: 05 January 2012 07:36 PM   [ Ignore ]   [ # 31 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1235
Joined  05-17-2009
CroNiX - 05 January 2012 07:29 PM

It does smile

Edit: or do you mean use an already loaded model so you don’t even have to specify one?

I was just browsing through the code and didn’t see the $this->load->model( $model ); Maybe I need to have another look.

Edit: Now I see it.

 Signature 

Brian
Brian’s Web Design - Temecula
Community Auth - CodeIgniter Authentication Application

Profile
 
 
Posted: 26 January 2012 09:39 PM   [ Ignore ]   [ # 32 ]  
Summer Student
Total Posts:  8
Joined  08-28-2010

CroNIX… do you mind giving a quick example of how you used it with a controller and a model, can’t seem to get your Form_validation library version to work.

Profile
 
 
Posted: 02 February 2012 09:09 PM   [ Ignore ]   [ # 33 ]  
Summer Student
Total Posts:  1
Joined  02-02-2012

Hey Brian,

Just wanted to say thanks, its a mighty elegant fix. This was one of the more annoyances of Form Validation (the other being that it only works on _POST instead on any input i.e _GET, _COOKIE etc)

E

Profile
 
 
Posted: 02 February 2012 09:13 PM   [ Ignore ]   [ # 34 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2537
Joined  02-19-2009

@ajustesen I’m sorry I didn’t see your post til now.  Please start a new thread and post what you have tried and I will help.  I don’t want to mess with Brians thread and I apologize to Brian for posting in his.

 Signature 
Profile
 
 
Posted: 03 February 2012 01:04 PM   [ Ignore ]   [ # 35 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1235
Joined  05-17-2009
erikig - 02 February 2012 09:09 PM

Hey Brian,

Just wanted to say thanks, its a mighty elegant fix. This was one of the more annoyances of Form Validation (the other being that it only works on _POST instead on any input i.e _GET, _COOKIE etc)

E

I’ve never heard of submitting a form with cookie data, but of course $_GET functionality would be useful. Glad you found the code useful.

 Signature 

Brian
Brian’s Web Design - Temecula
Community Auth - CodeIgniter Authentication Application

Profile
 
 
Posted: 19 April 2012 01:32 PM   [ Ignore ]   [ # 36 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  238
Joined  05-05-2009

just wanted to say thanks - this code is so awesome

Profile
 
 
Posted: 19 April 2012 11:54 PM   [ Ignore ]   [ # 37 ]  
Summer Student
Total Posts:  3
Joined  08-13-2010

Hello.

Thanks for skunkbad for solving my problem with Form Validation.

But still, I have some things needed to be solve here, it’s the error message.

Because we’re using the function external_callback, the error message only return the error for external_callback.

How can I return the error message from each of my model function?

Sorry for my bad english. Thanks for helping.

Profile
 
 
Posted: 20 April 2012 12:36 AM   [ Ignore ]   [ # 38 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  238
Joined  05-05-2009
chenx - 19 April 2012 11:54 PM

Because we’re using the function external_callback, the error message only return the error for external_callback.

How can I return the error message from each of my model function?

You always use the ‘external_callback’ error message - it will display the error for each of your models as needed

Profile
 
 
Posted: 09 May 2012 11:33 AM   [ Ignore ]   [ # 39 ]  
Summer Student
Total Posts:  6
Joined  03-15-2010

Hello,

Thanks, for this skunkbad. I looked at your community auth and tried to take the My_form_validation and use it in my project.

I am using HMVC so it did not work.

I also have my models organized in sub directories so the code could not find the specified model.

I have made a few changes that seemed to fix the problem for me…

public function external_callbacks$postdata$param )
 
{
  $param_values 
explode','$param );

  
// Make sure the model is loaded
  
$model $param_values[0];

  
//Alain: See if there is a path...
  
$model_pathexplode'/',$model );
  
$model_segmentscount($model_path );
  if (
$model_segments 1)
  
{
   $modelObj
=$model_path[$model_segments -1];
  
}
  
else
  
{
   $modelObj
=$model;
  
}

  $this
->CI->load->model$model );

  
// Rename the second element in the array for easy usage
  
$method $param_values[1];

  
// Check to see if there are any additional values to send as an array
  
if( count$param_values ) > )
  
{
   
// Remove the first two elements in the param_values array
   
array_shift$param_values );
   
array_shift$param_values );

   
$argument $param_values;
  
}

  
// Do the actual validation in the external callback
  
if( isset( $argument ) )
  
{
   
//Alain: now using $modelObj
   
$callback_result $this->CI->$modelObj->$method$postdata$argument );
  
}
  
else
  
{
   
//Alain: now using $modelObj
   
$callback_result $this->CI->$modelObj->$method$postdata );
  
}

  
return $callback_result;
 

Edit: I also need to enter the full path of where my model is in my validation rules…

So, if I did not enter a path, then this would not find the model, but If I entered a path, then it would find the model load it but when trying to use it it would reference the object with the path.

Profile
 
 
   
4 of 4
4