Race condition on Create record MVC 5 - ajax

I'm trying to build an application flow that works like this:
User visits a specific page
User clicks "Create new blog post"
Blog post record in database gets created, with default fields like {Title = "Your Title Goes Here"}
User directed to Edit page for that new record, with default fields loaded from DB.
I know this is backwards from the common flow:
User visits a specific page
User clicks "Create new blog post"
User directed to Edit page where they fill in all the info
User presses Submit, at which time the blog post record is created
What I'm finding is that in my flow, the record is being created in my BlogPostController, which does a RedirectToAction("Edit"), but the edit page is loading before the new record has been committed to the DB, so I am getting error 400 "bad request".
The reason I am flipping around the order is I want a more AJAXy editing experience that doesn't require an explicit "Save" or form submit. So I need to be writing data to the record as the user enters it in.
What is the correct way of doing this?

Related

What is the naming convention for Laravel store confirmation dialog

I have a form to create a new resource (for example a new user account). When the form is submitted, I want to show a summary of the data which the user has just submitted before actually storing this data. Under this summary, there is a confirmation button. When the button is clicked, the data is actually stored in the database.
What is the naming convention for the routes and controller methods in the following operations?
Displaying initial form
Submitting the form and responding with summary
Pressing the confirmation button and storing the data

PowerApps Portal--> After Record is created (Insert Form) show that record as Edit Form

I have a Insert form for Account Entity.
Once user create Record, I want to move to another page and show same record as Edit Form.
Does anyone have idea way to achieve this?
You should be able to redirect the user to desired page using OnSuccess of form submission.
On success: Select one of the following options:
Show success message: Requires a message to be displayed to the
user on successful submission of the form. You can also select Hide
form on success to hide the form upon successful submission.
Redirect to webpage: Redirects the user to the selected webpage
in the portal. You must select a webpage from the Redirect to webpage
list.
Redirect to URL: Redirects the user to the specified URL. You
must enter a URL in the Redirect to URL field.
Read more
Out of Box configuration helps!!!
There is a field on "Entity Form" records named "Append Record ID to Query String". This is to configure passing the id of the record to the page after form submission. This screenshot shows it in the Redirect Section in the classic interface
You can do this several ways. What I do, is use Navigate() to go to the new screen, and I pass in a context variable to the new edit screen.
Assuming you're using OnSelect() on a button to call SubmitForm(), you can do the Navigate() call via the OnSuccess() property of the form.
And within Navigate(), you just pass whatever data you need to in order for the next screen to properly bind it to the Edit Form. This is the UpdateContextRecord optional param. You'd have the Edit form take its values from a Context Variable.
Passing variables between screens has been discussed here, as well.

Database web frontend php, ajax, js

My skills in Java/AJAX are relatively poor. I am looking for a method or example link, that would enable the creation of a postgresql front end, that displays a record, the user clicks submit to edit the record changes. and Next to view the next one. The record would be shown within the text boxes within the page as it does when it is first created.

How to save form data (not in database)

I am making an application using ASP.NET MVC 3 which contains "form wizard", i.e. there are three forms which are wizards.
First form is for entering user details, second is for selecting product and third is for entering his payment details.
When the user enters his details in first form and goes to second form by clicking next submit button. And in the second form when the user selects the product, then his details from first form and his product choice from second form is sent to admin for approval. My question is that where should I save data from first and second form till users approval. When the user is approved then user data is saved to database. Where should I save form data when going from one form to other.
JavaScript Way
Just because "form1" and "form2" look like two physically different forms doesn't mean they have to be. You can initially display the container for the first set of inputs, then when the user clicks next it hides the first and shows the second.
Once the user is finished with the second set of inputs the page submits both sets of fields to the server using one form. At this point it would need to go in a database or be emailed to someone for persistence.
Traditional Way
If you need to have each form on a different page and submit between each one you could do it like this: (Note: this is a really bad way)
1. Form 1 submits
2. Server responds with form2 and data from form1 (to store in hidden fields on form 2)
3. User submits form2 (along with the hidden form1 data)

Joomla handling multiple ajax forms on the same page

I'm using Joomla to develop a user profile management component with AJAX.
The goal is to allow the user to edit his own user information. There is a lot of information so instead of having one massive form, I decided to make "subforms" or sections. And for the whole thing to be user-friendly I want to send the forms and refresh the user information with AJAX.
Here's an example :
There are two sections, "Basic user info" which displays the first name, the last name and the age of the person and "Extended user info" which displays the occupation, the company and the skills of the person. Each section has an "edit" link (or button) which turns the content into a form (AJAX) allowing the user to modify the presented information. You can only edit one section's information at a time. When the user has finished modifying the data, he sends the form with a "send" link (or button) and the section gets back to simply displaying the information of the section (with the updates that were just made).
So I need to know what is the most efficient way to develop such a component. I thought of two approaches :
1) In the "tmpl" directory of the main component view we the following files :
default_basic.php (displays the basic user information),
default_basic_edit.php (displays the form which allows the user to edit the basic information)
default_extended.php (displays the extended user information),
default_extended_edit.php (displays the form which allows the user to edit the extended info)
default.php (loads each of the display subtemplates with calls to JView::loadTemplate($subtemplate))
When the user clicks on an edit link, an AJAX call is made to the following URI index.php?option=com_userinfo&view=userinfo&subview=basic_edit&format=ajax, which causes the view class to call $this->loadTemplate('basic_edit') after assigning the user information to it.
If the user clicks cancel the same process is used to load the 'basic' template again. And if the user modifies the information and clicks the send link, the form is sent and then the 'basic' template is loaded too.
2) There is only a "default.php" file in the "tmpl" directory which holds the edit version and the display version of each section. But all the edit versions are hidden at first. And when the user clicks on the edit link the display version of the section becomes hidden and the edit version is displayed (using display:none and display:block). Then, if the user clicks the cancel button we do the opposite. And if the user clicks the send button we send an AJAX request to update the data in the database and return the updated user info which will be loaded into the display version of the section. And we finally replace the edit version of the section with its display version.
I know there's a lot of text but in the end it goes down to choosing between refreshing full HTML blocks with AJAX, or just sending the updated info and modifying the content of hidden blocks and then make them appear. So what do you think is the most logical approach, knowing that we are in a Joomla 1.5 environment ? How would you procede ? (maybe there are other ways to create such a component ?)
(I tried both ways and I couldn't entirely make it work so I decided to ask to see if it is a matter of conception...)
Thank you for taking the time to read all the text.
My answer is: why even refresh parts when it can be done without it?
For example when we are talking about basic form elements like text fields and check/radio buttons I would prefer the following: on a successful save/send simply display a nice message like "Profile saved" for some seconds and the user is sure that the changes are save and sound.
In case I msissed somthing let me know.
I have tried both solutions and #2 is the only one that worked for me.

Resources