CI's Form Validation with Uploader class, how? |
[eluser]JamieBarton[/eluser]
Hey guys, I have been looking at http://ellislab.com/forums/viewthread/133581/ I think that's sorta of my issue. What I have currently in my code before searching, is a form that posts to a controller, all thats inside the controller is something that requests a model. The model does the validation. My model: Code: function process_photo() I don't know how to then check the upload validation and inside of this and send back the errors as flashdata too. Can anyone help me? I always thought form validation should go into Models, but perhaps I have too much inside my model's function here? Maybe someone can help me clean it up better too? Thanks for your help. Regards, Jame
[eluser]JamieBarton[/eluser]
I've slightly changed my model now to return a TRUE or FALSE. But validation still remains in the Model, as I've been taught in the past to do. See the model: Code: function process_photo() My controller now looks like this: Code: function process() Now I don't know what I should do, should I have an else statement for the controller or not ? Since the ELSE insert into DB is handled with the Model? Where can I drop in the upload class and validation for that? How would I go about making the errors flashdata too. Regards, Jamie
[eluser]Muser[/eluser]
Hi, There is an user community contribution in this forum with an extended MY_Form_Validation class file that performs upload validation. At this moment I can't remember where it is, please search it in this forum or at the wiki. And the question about flashdata errors I suggest to you another implementation. Only use flashdata to send success messages, because to display them you need to do a request to another page (for example, a redirect). For display error messages use validation_errors() and form_error(), and for repopulate data use set_value() form helper's function. |
Welcome Guest, Not a member yet? Register Sign In |