validation not working |
Hi, I'm a newbie and I want to ask you something about validation.
I just created some rules for form validation. This is my Controller : Code: public function create() This is my View : Code: <form action="/Home/create" method="post" enctype="multipart/form-data"> But when I tried to submit the form with the empty field and I dd($validation->getError('name')) the return is empty error data. My PHP Version : 8.2.12 My CodeIgniter Version : 4.5.5 Please Help Me, Master.
I have been a CodeIgniter user since version 2, I assume, when direct access to databases didn't even exist, and despite all this time I am aware that I am an amateur. There is a proverb that says: "The devil is wise not because he is the devil, but because he is old." I am not the devil, much less wise, but old. I am taking all this care so that you do not misunderstand me or believe that I am arrogant.
The system may have a validation error, but up to the point described I believe it is a semantic error. Validation means that something will be compared to one or more rules, if that something does not exist there is nothing to validate, and to do so you do not need to write a single line of code, just put "required" in the form input field, the user will receive a message that the field must be filled in and will not be able to submit it until the condition is met. <input name="album_id" size="10" required> I believe that "Field Name is required." It's not very clear to the system. When I saw the error thread, I thought it was a problem I had right after the release of version 4.0, and unfortunately, the support team at the time justified the error. What can I say about that? As they say around here, "I'm not going to beat a dead horse."
If plan A fails, relax... the alphabet is 26 letters
(09-16-2024, 04:47 AM)wdeda Wrote: I have been a CodeIgniter user since version 2, I assume, when direct access to databases didn't even exist, and despite all this time I am aware that I am an amateur. There is a proverb that says: "The devil is wise not because he is the devil, but because he is old." I am not the devil, much less wise, but old. I am taking all this care so that you do not misunderstand me or believe that I am arrogant. But when I down grade the CodeIgniter version to 4.0.3 my validation with same condition is working. Code: <input name="album_id" size="10" required> This way is no problem, but it does not mean you don't need to validate in PHP code. Because if attackers come, they can send requests without album_id field easily. So if you don't check the field exists in POST data, invalid data might be processed.
Did you set $validation to the view?
(09-16-2024, 07:23 AM)Anharr Wrote: But when I down grade the CodeIgniter version to 4.0.3 my validation with same condition is working. If you app code rely on a bug, when the bug is fixed, your code might not work any more. I don't know your case is the case, but check the following bug fix. https://codeigniter.com/user_guide/insta...ion-errors |
Welcome Guest, Not a member yet? Register Sign In |