TagField lazy load shouldnt render Options

TagField should only render options if the lazy load value isn't set. Options from here come from subsequent POSTs, and rendering the options for every request significantly slows down both the form generation and render.
This commit is contained in:
Simon Gow 2018-09-07 17:28:05 +12:00 committed by GitHub
parent 3797049a31
commit fa754f3fd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -262,6 +262,20 @@ class TagField extends DropdownField
$ids = $values->column($this->getTitleField());
$titleField = $this->getTitleField();
if ($this->shouldLazyLoad) {
// only render options that are selected as everything else should be lazy loaded, and or loaded by the form
foreach ($values as $value) {
$options->push(
ArrayData::create(array(
'Title' => $value->$titleField,
'Value' => $value->Title,
'Selected' => true, // only values are iterated.
))
);
}
return $options;
}
foreach ($source as $object) {
$options->push(