• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Break out and return to edit form

[eluser]Kenneth Allen[/eluser]
While I have been programming for too many years (everything from compilers to space craft telemetry) I am relatively new to web programming, and CI in particular.

I am developing a web app to manage 'seasons' of Little League baseball, and I have run into one of those things that seem to be difficult to do with web programming, but which I handle as a regular event in desktop programming (usually with modal dialogs that can be invoked from multiple places).

I have an edit form where the user can create a new or edit an existing element, which is working fine. One optional field in the table is a user ID, and I have this displayed as a drop-down that permits the user to select one of the qualified entries from a database table. This works fine and the record can be saved with or without such a user reference, and it can be changed at will.

The issue I am struggling with is how to permit a new user record to be entered on the fly! I can only see three options, and they all have difficulties.

1. Add a link to an "Add User" page and handle it as it would be handled from anywhere else -- but how do I get back to my original edit form with the original data, some modified by the user, in place.

2. Add a link that opens a new window to permit the user to be added -- but how does the original page know that this was completed and thus update the list of users in the drop-down?

3. Add a second form to the edit form page that permits the user to be created -- but where would the 'submit' button direct control to actually add the user, and how do I get back to my main form with the updated user list and any pending edits made by the user?

Perhaps this is rudimentary stuff and I just have not tweaked on the proper search phrases to find samples of a design pattern for this, so please forgive me if this is basic stuff I should be able to find on my own.

Hi, the way I normally deal with this sort of thing is as follows

1) Make te first/last option in the drop down "Add new user"
2) When this is selected, it triggers an event via JS, which changes a hidden div below to be visible
3) The now visible div has the required fields for adding a new user, and is part of the same form
4) When the user submits the form, if the "Add new user" entry was selected, first create the new user and insert them into the database and get the ID (using db->insert_id()) and then carry on as normal
Or if it's an existing user, carry on as normal

On their own web apps suck for interactivity, and that's where the wonderful world of Javascript comes in, specifically AJAX. Look into jQuery, that will give you a lot of what you're used to being able to use (events, modals, updating forms based on user action and so on). What you essentially will end up with is CI/PHP on the server side handling the processing and jQuery running client side enhancing the UI. Ideally you want to write your app so it works if JS is turned off (graceful degradation) but if you couldn't care less about the non-JS users then go to town with all the UI stuff. jQuery is of course not the only javascript framework out there (just happens to be my preference) you could also look at mootools, Dojo, YUI plus a bunch of others.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.