I have a CodeIgniter webpage containing (i) a list of items and (ii) a form to add a new item or edit the details of a selected item.
To select an item for editing, I have an "edit" anchor tag with a hyperlink ending with ?id=nnn. This results in a GET request that populates the detail fields of my selected item and redisplays the list. My URL now contains site_address/index.php/country?id=151.
When I submit my changes the list is updated correctly but my URL remains unchanged. What do I need to do in my controller to remove "?id=151 after my update was successful?
Thanks for your help.
I'm not sure of everything you are doing, so I'll just answer directly:
in your controller, after you update, you can:
redirect('site_address/index.php/country');
Does that fit what you mean?
Through php there's no way to change URL after request expect redirecting
redirect('controller/method');
and you can success message using session flash message after redirecting, if that what makes you want to reload the view
Related
I have used Fresh MVMM. I need to pass a data from one page model to another page model without using init and reverse init.
Eg: I have one toggle button in first content page.
I need to toggled the button based on the selection in second popup page without popup the second PopPopupPageModel.
ReverseInit is worked when popup the second PopPopupPageModel and can easily pass data.
But I need to toogled the button in first page without popup the second page.
Please help...
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.
I have a select box in my view.ctp , it shows some content from the controller, but my problem is i want to load content dynamically according to the droapdown selection
i tried with making ajax request on onchange of selection in the select box. but the problem is ,the select box id is sending to the controller function, their i set the content for display .but the page is not refreshing..
I dont know which logic sholud use for this purpose..if anybody have an exerience with this..please replay me..
In order to achieve those results you should follow the next steps:
Create an action that returns the content with $this->layout = null
Create a view for this action that displays the content in the way you desire (html with no css)
In the view that you like to fetch that content through AJAX make a request that pulls that controller and view
append it where you want it on your page (with proper css on the page you make the request it will display correctly)
I have a web application which among other things contains a table of items created using an Ajax callback. A bunch of form fields at the top of the table allow me to filter the items that will be displayed in the table according to various criteria and show it.
Some parts of the table have lists of items with an [X] marked next to them that I can delete by clicking on those items.
Now, if I were doing this the non-ajax/javascript way, the page would receive a bunch of POSTed data fields and then would render the table accordingly. I can do this but I would also like to Ajaxify the entire setup. My questions are regarding this.
How would I create the [X] button. A simple <a> would "work" but it's a GET modifying state so I don't want to do that. The way I'm doing it now is a tiny form with a hidden parameter than holds the item to be deleted and a styled submit button that's the [x]. If I ajaxify this, I can get the response and do the needful.
How do I keep my backend DRY? I don't want to have two completely different bits of code for the Ajaxified version and the regular ones. What I'm doing right now is having the non-ajax version submit to a URL that changes the state and then redirects to the main page again (similar to a PRG type system). With the Ajax enabled, I simply call the URL and ignore the redirect but use the returned data to adjust the table. Is this the "right way"?
Any other advice on graceful degradation on how to keep my backend DRY?
I would put each row into it's own form (with method='POST'), and include a hidden field to say which item is to be deleted. The [X] would submit the form, and in the form's submit event, if no XmlHttpRequest is present simply submit the form to the server which would delete the item and redirect to the same page again (this is good practise to avoid a reload from resubmitting the delete POST).
If an XmlHttpRequest is present, set it up to POST with the id of the thing to delete and then remove the row if the request succeeded. You could set a flag in the AJAX request so that redirect doesn't happen, just a success (200 OK).
I would like to implement a dropdownlist with some listedItems.After that I want for every selected item to be connected to a new aspx page(i.e. if I select meat I want to have a new aspx page that will contain some information about the meat). Does anybody have any ideas? Thanks,
Naim
Set the Value of your ListItem to the URL you want to redirect to when the item is selected. When the user selects the value, simply redirect to that URL.
This can be done in either Javascript or serverside. I'd prefer doing it in javascript to avoid the extra server roundtrip.