1

I am looking for a way to create a table entry form for an entity type. We are trying to create an invoice form. I am currently using a field collection for each invoice line.

Order (node)
  Invoice (node)
    Invoice line (field collection)

I am currently using the field_collection module along with field_collection_table. I am using entity reference to connect the invoice to the order and invoice line This works great except when we have more than roughly 75 rows. At that point we are unable to add new rows to the table. Users are getting a 500 AJAX error.

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Internal Server Error
ResponseText: 

Originally I received an error about max_imput_vars limit of 1000 when we got to about 50 lines. I have since changed the limit to 100000. Now nothing shows up in the server error log or the Drupal recent log messages. My PHP settings are:

memory_limit = 256M
max_execution_time = 120
max_imput_time = 120
post_max_size = 160M
upload_max_filesize = 128M
max_input_vars = 100000

My thought now is to create a custom entity for invoice line. The trouble is how to display this entity as a table and allow users to edit multiple items at once. Some invoices could have 500 rows and I need a way for users to be able to quickly move from line to line. For non-Drupal forms I have used jQuery to dynamically add new rows to a table. Not sure how this would work for Drupal since each field in the table has an id that is specific to each row (e.g. edit-field-desc-und-31-value).

Any suggestions? A separate but important issue is a need to regularly autosave. Users would not be happy if they added 300 rows and lost power, computer froze, or something else happened.

  • Have you looked into Editable Views? – Melissa Nov 11 '15 at 18:45
  • Thanks Melissa... I just took a look. Very interesting module however I do not see a way to add new rows. – sho Nov 11 '15 at 19:11
  • You might have to add that functionality on top of it through theming or a custom module. I'd look into an "infinite scroll" pager. – Melissa Nov 11 '15 at 20:24
0

We ended up going the route of a custom field collection table module combined with batch processing. The problem was the standard Drupal way of adding rows using ajax. Instead we created the rows dynamically using Javascript to duplicate the last row and all associated features tied to each field. We then used a batch process to save the data. This resolved the issue of the server timing out with lots of rows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.