Needs work
Project:
Multi-value form element
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Feb 2021 at 13:01 UTC
Updated:
1 Jul 2026 at 05:10 UTC
Jump to comment: Most recent
Comments
Comment #3
dieterholvoet commentedComment #4
roderikI wanted to create a patch but it's probably best to add to this one, because functionalities overlap.
I have a feature request to optionally not add an empty item. In my use case, I have a big textarea element for a configuration value that is multi-value in theory, but most often has just one value. So I need the 'add another item' button, but I'd like to not display the empty second textarea by default.
So I added support for
I can understand if you don't like the values FALSE or 0 being different. Just one thing: with this setup it would be trivial to support #add_empty = 2, 3, ... to add several extra empty items by default (with 1 being the default #add_empty value).
--
Also:
Comment #5
roderikFixed a bug I introduced in the interaction between the "add new item" button + #add_empty=FALSE.
(If the element has no values yet, it was adding 1 element to the display. But after pressing "add new item" for the first time, it was still displaying 1 element.)
Questions:
These are possibly dumb questions -- but If I'm missing something re. workload, and in practice only people who work at DIGIT can get things pushed through... maybe I should write a job application before writing automated tests ;-)
Comment #6
sardara commentedI will take a look today or tomorrow at this PR. I've been thinking about the original scope of the issue already, but to be honest I tried to keep the form element as close as the core functionality as possible.
Regarding PRs, as I wrote in the other issue will we fix soon (hopefully) the tests to be run. This module has full (again, hopefully) test coverage, so any PR will have to provide test coverage too here.
No need for Github PRs, we will sync them back there.
Comment #7
roderikThank you. Feel free to cut off my commits (maybe except the first) if it's easier to commit just the initial scope. I'll be doing some other things before writing tests for this.
[edit] but/and I'll also wait for your opinion on whether #add_empty can/should be added to this module at all.
(Re. closeness to Core functionality: I did indeed see that the standard functionality matches that - and didn't change the default behavior,)
Comment #8
hnln commentedThis patch does apply on beta6, but throws a notice:
Warning: Undefined variable $max in Drupal\multivalue_form_element\Element\MultiValue::processMultiValue() (line 234 of modules/contrib/multivalue_form_element/src/Element/MultiValue.php).Comment #9
super_romeo commentedSame thing with dev-version.
Comment #10
aaron.ferris commentedIm seeing the same notice, although the Delta feels a bit odd in its original state, doesnt this mean every element _weight array has the same delta?
Comment #12
strykaizerFixed issue with reference to $max variable
Fixed issue for required multivalue fields, to ensure we always keep at least one element, if the multivalue field is set as required.
Comment #13
darvanenThere are some CI failures.