By iztok on
I am looking for a solution for multiple values fields that have the "add new item" buttons but does not do AJAX request. I understan why it has to do that request but I al looking a way around this so my application can work faster. Is loading 10 empty values and hide/show them with jQuery really the only option?
Thank you for your feedback!
Comments
Three approaches that could
Three approaches that could work
a) Use the "Add more" using AJAX
b) Might be able to do "Add more" with javascript disabled, would produce a page reload (slower than (a))
c) Use the Form API to output some maximum number of fields plus a hidden value to track how many are visible and use jQuery to hide/show fields and keep the counter up do date. Would take some work to make the field API use this.
I am of course looking for a
I am of course looking for a solution on c). Weird that there were no other requests about this do far. Only thing I read is that the form needs to be rebuild so it know how many fields will it accept - basically if you send too many form values you will get a validation error.
Looks like this can be overridden with some custom form alter code. Does anyone has any ideas hot to tackle this one?
Thanks!
--
twitter: @Iztok | company: Drupal Theming & Development Studio
You have two options, and you
You have two options, and you outlined them both already. Load everything at page load, hide it, and show the new elements using javascript, or only load some of the elements at page load, and use #ajax to load additional rows. It's up to you which you choose to use.
Contact me to contract me for D7 -> D10/11 migrations.