0

I have multiple files and input text in my form. My code is :

if(formValidationIsGood) {
   if(customeCheckFileErrorIsEmpty) {
      //StartProcess
   }
   else {
    //I load my view with my array which contains the different error related to the files.
   }
else {
    //I load my view with the form error (set up by : $this->form_validation->set_rules('variable', 'Variable', 'required');) But if there is an error for the files I cant display it.
}

With this code I can't show the form error and the files error at the same time. For example the user, is uploading an csv file instead of a pdf file, and he forgot to write into a text input, the form error will be displayed but not the file error and vice versa.
Obviously I am using the helper file provide by code igniter.

1 Answer 1

2

Since you want to display error messages for either A OR B, you can try this:

if (!formValidationIsGood || !customeCheckFileErrorIsEmpty)
{
  // load the view and display whatever errors you found
}

else
{
  // form validation IS good and the files error is empty
}

The if clause above will evaluate to true if either formValidationIsGood ISN'T true (the ! prefix is key) OR the customeCheckFileErrorIsEmpty ISN't true (which would mean there is an error)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.