codeigniter form prepopulation - codeigniter

Is there a method to prepopulate a certain field in a form using data from the previous page using codeigniter.
I have a page with input fields that are filled out, if the user presses a "add" button they are given a new form with similar fields. I want those fields to be populated from data received by the previous page.

You can use CI's form helper function set_value() which uses the $_POST and may save you some code testing if the $_POST value is empty because you can specify a default value if not set. Should be using this anyway if your using CI's form validation.

Can't you simply use the $_POST data to display the second form?

You could store the data entered in form 1 in sessions or in the database and display it in the second form. Or as mentioned use $_POST in the second form to retrieve submitted data from the previous.

Related

Edit Redux Form with FieldArray

I have create a Redux Form with FieldArray as mentioned in its example, where you can add multiple Member and Hobbies and Submit the Form.
https://redux-form.com/8.1.0/examples/fieldarrays/
Can we Edit the same Form by accessing the form from database? The Edit form should display all the fields and Button I have created before ?
Please advise how different sub-component(which is created using FieldArray ) will populate the values.
Thank you
You can reuse the same form for editing.
A field array is mapped into redux as array of objects or array of strings (depending how you do the fields.push).
If you provide that exact format to the initialValues prop when you mount the redux form, it will populate the FieldArray accordingly

How can i get data from database for dropdownlist in Form in Laravel using laravel collectives?

I have used usual dropdown list and it's not worked,
when i click the submit button for all the data in the form except drop down value were sent to database.how can i fix it??
Your <select> is missing a name="foo" attribute.
A form will only submit elements with a name as part of the request.

asp.net mvc - Data lost on post back

I have a form that only has a checkbox. If the checkbox is not checked then the page won't be valid and won't submit the data. On the view I have out putted some fields from the model object, just to let the user know what they are deleting. When I click the Submit button and the model state is not valid the page will show the validation error but the data from the model is no longer there!
Does anyone know how I can persist this data without making another call to the database to populate the model object?
Thanks
ASP.Net MVC will not magically persist model info.
You need to either include it in hidden fields in the form (which an attacker can modify), or re-fetch it from the database.
If you don't repopulate the Model from the DB, you have to postback all the data, using hidden fields for example.
Anyway, I don't understand how the model validation could fail, being just a checkbox :/.

How to pass rows added client-side in MVC3 webgrid back to controller?

I have a Model that contains some string fields and a List. In the view I use EditFor for the fields, and want to use WebGrid for the List.
Display works fine. But then I use jQuery client-side to let the user add rows to the table generated by the webgrid, which also show up fine on the UI.
However these rows don't appear to be tied back to my model's List upon a submit. In the controller I see that the posted model's string fields contain whatever was entered by the user. But the model's List is empty - it doesn't contain the original values nor the newly added values.
How can I cause the model posted back to the controller to be fully populated, including whatever the webgrid-generated table looks like now, just like fields are?
I see several other questions like this for webgrid on the forum, but none with an answer.
I suppose you are comming from WebForms world. Well this is different in MVC. Here you are back to plain old html and its input fields. No viewstate to hold your rows. Check this link: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx.
Basically you need have consecutive index (or ID) for each row.

Can a CRM 3.0 PreCreate callout fill form fields in advance?

I just finished my first CRM callout, and it's working great, but it doesn't actually seem to take effect until the form that calls it is saved. It's a PreCreate deal that assigns a value to one of the attributes present on the form. Is there any way to get it to assign the new value and display it on the form as soon as you load it, or is this just the way it works?
You'd have to add some JavaScript to the onload event of the form and default any form fields that way. Callouts don't fire until after the save event happens, so they can't be used to default fields in the UI.

Resources