Ok I am hitting a wall in a scenario I think I do not quite understand.
Senario - I am building a stock control app. It has the ability to purchase products in a grouping called orders. I am at the point where the app will receive a delivery in and the user is reconciling the delivery (matching orders to deliveries - correct products per order, correct product qtys, no damaged goods etc). I currently have no model to hold the reconciliation action so was managing the user activity of matching order products and qtys via a Json container. This works well and I can pass the completed reconciliation to a view called receive_delivery. receive_delivery has to loop through one or more orders, and each order can have one or more products, and each order can be a standard order or custom order. So what I was trying to do is begin a loop within the received_delivery view. If an order is a standard order pass a list of its products and the reconciliation decisions (qty counts and notes) the user made on the reconciliation page, to a function that would called handle_standard_order. This function/view handles one order at a time. handle_standard_order will then to loop through each product from the Json it received and render a page that asks the user where each product should reside (in a building and on a shelf etc). Once this list of products is stored, move to the next list of products which receive_delivery passes on a return of store of order completed that includes the storage location decisions the user just made.
This sounds more complicated that it is. However the point is the data flow starts at a page feed from one view. On submission the data is not written to a model, but rather passed in a Json container that is sent to a view which has a loop within it to process the incoming Json. To complete the loop data must leave the receive_delivery view in small subsets into other helper view/function, its return sets off the next subset it has to process, until no more subsets exist within the receive_delivery main loop, at which time the main loop within receive_delivery ends, and the view renders a page back at a orders home page.
So while each subset of data is processed by the helper function, the main loop within receive_delivery is paused waiting for the subset returns.
Within the helper function I want to ask for User input to feed the decisions of storing products. Each subset return from handle_standard_order to receive_delivery has these user feed decisions in it, receive_delivery takes each return applies these to the model and starts the next subset if one exists, until no more subsets are in the for condition.
Issue: Data enters the view receive_delivery in Json format just fine, and a for loop of the orders is created. if the data needs to leave receive_delivery to (in this example its a standard order that needs storage locations confirmed by user input) a subset of products is generate and Json is passed to a helper function handle_standard_order.
The subset of the original Json is passed between receive_delivery and handle_standard_order seems to happen without issue.
The problem occurs when handle_standard_delivery needs to render an html page to ask the user for input.
No matter how I write receive_delivery view or handle_standard_order function the render within the handle_standard_order view never fires. So the User is never prompted for input, and thus no decisions about storage locations is made.
handle_standard_order simply carries on looping and then returns to receive_delivery, which completes its loop without the correct returns then fires it last render and throws the user back to a list of orders (the orders home page, which is where I want them to go once this exercise is actually complete).
If I write both receive_delivery and handle_standard_order and do not write in any renders to get user input, but simply make arbitrary storage location decisions based upon storage locations that exist within the model. the for loops work without issue.
So my question is. Can you ask for User input in the middle of multi loop data flow, specifically if the render happens in a helper function to the main view fired? or do I need to handle all user inputs before any view loop fires?
Kind regards
Duncan