Welcome Guest, Not a member yet? Register   Sign In
JQuery with forms help needed
#2

[eluser]slowgary[/eluser]
I found your description and code difficult to read. Have you copied and pasted your code from word? It has the non-standard double quote characters. You're a microsoft junkie, I can tell. Smile

Anyways... it seems like what you're saying is that your form allows a user to "add a field", but when the user submits erroneous values, the form is repopulated minus the added fields. How can you retain the added fields?

I don't have the exact answer to your problem but you could probably iterate through all post data and add those fields to your form validation and view. You really should consider cleaning up your JavaScript for the next guy in line (or yourself, 6 months from now). Also, you're using the highlightFade plugin which is obselete (as claimed by it's creator) due to the addition of custom animations to jQuery. See if you can do something like this in your controller:
Code:
foreach($_POST as $key => $value)
{
     $data['custom_fields'][$key] = $this->input->post($key);  //get each form field to pass back to the view
     $this->form_validation->set_rules($key, $key, '');  //set a validation rule for each form field (or blank for no validation)
}

$this->load->view('form_page', $data);  //call your view

Then in your view you'd just iterate through the custom_fields and echo out form elements. I haven't tested this but you should be able to get something like it to work. I'm not sure how you'd manage setting real labels for each field in the form validation, or how you'd present each form field in the view, but I guess depending on your app maybe something more generic would work. That's for you to figure out.

Good luck.


Messages In This Thread
JQuery with forms help needed - by El Forum - 07-09-2009, 02:44 PM
JQuery with forms help needed - by El Forum - 07-09-2009, 10:15 PM
JQuery with forms help needed - by El Forum - 07-09-2009, 11:23 PM
JQuery with forms help needed - by El Forum - 07-10-2009, 01:57 AM
JQuery with forms help needed - by El Forum - 07-10-2009, 08:22 AM
JQuery with forms help needed - by El Forum - 07-10-2009, 11:10 AM
JQuery with forms help needed - by El Forum - 07-10-2009, 11:23 AM
JQuery with forms help needed - by El Forum - 07-10-2009, 11:39 AM
JQuery with forms help needed - by El Forum - 07-10-2009, 12:28 PM
JQuery with forms help needed - by El Forum - 07-10-2009, 01:16 PM
JQuery with forms help needed - by El Forum - 07-10-2009, 01:25 PM
JQuery with forms help needed - by El Forum - 07-10-2009, 01:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB