Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
validation on 2 inputs
  • I have a form with several inputs but 2 of them are combined (id and key)
    These two inputs will be checked using an online api. The api gives a unique error number when the authentication is invalid. Let's say this is the validation code:
    public function _validation_api($api_id, $api_key)
     {
      $api = new Pheal($api_id, $api_key);
      try{
       $result = $api->Characters();
      }
      catch(PhealAPIException $e)
      {
       if($e == 202)
        return false;
       else
       {
        return true;
       }
      }
     }
    
  • Write your own rule, and there's 2 options: 1. if it will always be send via POST you can just check the other value using Input::post('var') 2. fetch the very latest develop and get it from the currently running validation instance: Validation::active()->input('var') - only available in rules while the validation is being run. Outside it being run you can just request ->input() on the validation instance.
  • Using the example from the Docs, I could validate unique record on creation. That is when count == 0 it means the record is unique.
    Now, when using the same rule on update, it fails, as there will be at least one record (the one I'm editing) that has the same info.
    The best solution in my case may then be to use add_model(Model_Users) which I don't know how to implement.
    Can you please help?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion