Welcome Guest, Not a member yet? Register   Sign In
Probably something simple...Form repopulation
#11

[eluser]Militis[/eluser]
Ah, alright thanks. I'll go through and fix this tomorrow.

How would you suggest I differentiate between just loading the form and the form having been submitted, but has errors? I've tried something like:

Code:
if ($this->input->post('submit')) { //submit being the name of the button
//run validation, and do the CRUD dance if it passes
} else {
//load the view with the form
}

but I wasn't sure if that's how you do it or not. That would be how I'd have done it before CI, replacing $this->input->post with $_POST of course. I'll need to do this for the edit aspect of this app, since it needs to populate the fields for editing.

Reducing this to only one function per form would also reduce some of the bloat of my fat controller...(I think that's the term used for it being over 500 lines, respective of the complexity of the app, long anyway... My model is pretty close to the same, but that I would expect...and it's easy to split if need be.)

I'm rather taken with how easy it is to separate things now. Having to change something is so easy I weep at past hours/days/weeks of search and replace.
#12

[eluser]TheFuzzy0ne[/eluser]
That's exactly the way I'd do it. Smile

I think you've got the right idea. As for bloated code. That often happens when you're doing things as simply as you can. Refactoring is where it gets fixed. Simplicity comes first, elegance generally comes after everything is working as it should be. Smile

Right. 6AM - Bed time!
#13

[eluser]Militis[/eluser]
Thanks again for the help. It is greatly appreciated. I'll post my controller and view again after it's fixed up (this time it'll be the edit part, so I can make sure it's right too...Before posting, it needs to get the info from the DB, but after it should be repopulated if there are errors).




Theme © iAndrew 2016 - Forum software by © MyBB