Populating a form from a database then validating it |
[eluser]the future darlo manager[/eluser]
Trying to sort this out but struggling a little. I want to just use the one view to show the form which is causing me the problem. I want to query the databse, populate the form and then when the form is processed validate it and redisplay it if need be. Any solutions... this is what I've got so far but can't get it working. Obvioulsy '$row = $article->row();' is causing the problem in the view but I'm stumped how to get round it. Code: function editarticle() Then the view... Code: <?php
[eluser]xzela[/eluser]
can you model your model? more specifically the Articles_model ?
[eluser]the future darlo manager[/eluser]
I've left it at work unfortunately so would have to do it tomorrow morning. Its just a standard MySQL to get my article (SELECT * from articles WHERE article_id = $article_id LIMIT 1) type thing. That query is working as I use it to pull an article up with it elsewhere in my app and I can get it too populate the form here. Its when I submit it and need to redisplay it with validation that I'm stumped on as I have to use the validation variables. I guess I could create two views (one for validation and the other for loading the original content into) but it seems a bit silly when I might be able to do it with on.
[eluser]xzela[/eluser]
Hi, So i have rewritten your code to what i usually do. This is just a personal preference. You can take it or modify it to your liking: by the way i haven't tested any of this, but it should work. Article_model Code: //Model stuff Controller_name Code: //Controller stuff View Code: <div id="container" class="page"> Let me know if you have any questions. I'll try my best to explain stuff. good luck on your site.
[eluser]the future darlo manager[/eluser]
Thanks for the help. It was much appreciated. Managed to rework your idea along with the idea presented in the link here (http://ellislab.com/forums/viewthread/103419/) to get a fully working system using just one form. Very happy indeed. Hopefully I can crack on with finishing the site now. Its actually already built without a framework but its become large enough now to justifty a move. |
Welcome Guest, Not a member yet? Register Sign In |