Getting Error: Warning: array_values() [function.array-values]: The argument should

I can confirm the error:
#_fabrik_form_session truncated
Form set to "save partly"=no
Menu item with fabrik list

edit a record
submit the form with a validation error
-->

  • you can see a new entry in #_fabrik_form_session
  • (do anything else)
  • return to your list and edit any record (not necessarily the one where you got the validation error)-->
  • the elements are empty and it's showing the validation error messages (above the form and the element's one)

go back to the list and edit again (any record): all is ok
 
So in step 2, "do anything else", is that "anything except submit the form"?

IOW, if you submit the form again (without validation errors), does that clear the form_session?

-- hugh
 
Yes, if the form is submitted with correct values the form_session entry is deleted.

But if you leave the form with validation error (e.g. to look up something), then return to your list, the list view will show the correct (old) values (because the record with the validation error wasn't saved), but editing ANY record will give you an empty form + the validation error messages.
If you fill and save this empty form you get "record added.." but nor the original edited record is overridden nor a new one added.

Going back to the list and edit ANY record again is ok (although the form_session entry still exista and is only cleared if this record is submitted again).
 
Can you confirm that you are seeing the same effect I am:

Trigger a validation fail.
Go back to list.
Edit another row.
Blank form comes up with generic validation fail msg.
Reload the page, and the correct form comes up with no errors.

-- hugh
 
With regards to the form session entries staying and only getting cleared when you submit it without validation failure, I think we need to have an configurable time-out on those session table entries, and do garbage collection whenever we do a getSessionData() in the form model, i.e. ream out timed-out rows before reading the table.

[This is a separate issue to the main one I'm looking at right now, where editing a different row is fubar'ed]

-- hugh
 
Can you confirm that you are seeing the same effect I am:

Trigger a validation fail.
Go back to list.
Edit another row.
Blank form comes up with generic validation fail msg.
Reload the page, and the correct form comes up with no errors.
Yes. But it can be also the same row.
 
OK, at least we're seeing the same behavior. I just can't immediatey see why it's doing this, as it never seems to even call getSessionData() on that first problematic load.

Stepping through the code with xdebug now.

-- hugh
 
Hmmm, OK, I see what the problem is, but I'm unsure as to why this has suddenly started happening, as it seems to involve code which hasn't been changed.

Basically, when we render the form, we check the session for errors, in getErrors() in the form model, using the context:

PHP:
		$context = 'com_fabrik.form.' . $this->getId() . '.';

... and ...

PHP:
$errors = $session->get($context . 'errors', array());

So for a form with ID 123, the context is com_fabrik.form.123.errors. Which doesn't take in to account the row ID. So when the validation fails for a row, we store the errors in that session context with just form ID, which doesn't get cleared if you don't submit the form, then when we load the next row from a click on the List for that Form, we end up loading the un-cleared errors from the session, regardless of the row ID.

NOTE that this is separate from the form_session table stuff, which is designed to store uncompleted form data over greater lengths of time. This is standard J!/PHP short term, session data, really only intended for storing short term session data across page loads.

I'm not sure if what we need to do is:

1) Use the rowid in the session context when setting and getting the erros between page loads.

2) Clear that context when loading a form from clicking on a list link.

3) A combination of 1) and 2).

I think I need to get The Boss to have a look at this.

-- hugh
 
OK, I committed what should be a fix for this, can someone test and let me know.

I suspect there may still be oddities happen if you go back and re-edit the same row, and potentially if you create a new form, fail validation, then create another new form.

But this commit:

https://github.com/Fabrik/fabrik/commit/e2a580c8b489588af6a80287fb5840039915bdfa

... should fix the main problem, where editing ANY row after failing a validation (and not doing a succesful submit) would screw up.

-- hugh
 
Seems to be ok if editing an other row.

But returning to the same row (the one which had the validation error) will show
an empty form with error message

Going back to list a second time the list view is showing the correct (old, not modified) values, editing again this row will show no error message but the form doesn't contain the list values but the values inserted during the "validation error" edit (I assume the ones stored in form_session; but form's "save partially...multipage" setting is NO)
 
Hi Hugh,

I have made changes to the file 'form.php' in components/com_fabrik/models. But the issue still persist.

1. When the user fills the form and and submit, validation error messages displays, if any required field entered with wrong details / not filled. But, except the main 'FORM', all other forms data in the group is removing, so, user has to enter the details again! This is really an annoying thing.

2. When the error messages displays, if I refresh the page / navigate to some other pages and come back to the Fabrika form page, the error messages are still displaying.

Note: I think, if the user navigates to other pages / refresh the page, the error messages should be disappeared.

** Especially the form data should not be removed when the page reloads upon validation.

Please find a solution.

Thanks,
Ramki
 
OK, I was able to replicate this for a one-to-one join, but not for a repeated join.

Are your joins repeated?

I don't have time to work on it today, but I'll get it fixed over the weekend.

-- hugh
 
Hi Hugh,

My Joins are not repeated. I PMd you my site logins, please have a look it.

Issue I

1. Login with the Login ID, PWD.
2. Click 'Sell Your Product' link on Main menu.
3. Fill the form and leave a mandatory form on it, and click submit.
4. You can see the first form details not removed, but all other on the same page will be removed.

Issue II.

1.Submit the form without filling any details, the validation messages will be displayed.
2. Navigate to any other pages on the website, and come back to the 'Sell Your Product' page, then the error messages still displays.

Note: The above issue is happening even after I made changes as per your instructions. So I replaced the changed form 'form.php' with the old 'form.php'.

Thanks,
Ramki
 
I probably won't need to login to you site, as I was able to replicate this issue with one-to-one joins.

Can you confirm one thing for me.

On your Join settings, do you have a foreign key (FK) on the main table, pointing to a primary key (PK) on the joined table, or vice versa?

In other words, do you have something like main_table.joined_id pointing to joined_table.id, or joined_table.main_table_id pointing to main_table.id?

-- hugh
 
Yes,

One main table has a primary key (virtuemart_product_id), and it is a Foreign Key on other tables.

So, I used the Primary Key to join different tables, so as you said this is causing to loose the data on fabrik form when page is refreshed.

Please see the attachment to see how I joined the tables.

Sorry, the image is very long, if you can't see it properly, save it on to desktop then see.

Thanks,
Ramaki
 

Attachments

  • Joins.jpg
    Joins.jpg
    50.1 KB · Views: 285
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top