Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazyloaded SearchableDropdownField does not work in elemental #1778

Closed
emteknetnz opened this issue Jun 11, 2024 · 1 comment
Closed

Lazyloaded SearchableDropdownField does not work in elemental #1778

emteknetnz opened this issue Jun 11, 2024 · 1 comment

Comments

@emteknetnz
Copy link
Member

emteknetnz commented Jun 11, 2024

Lazyloaded SearchableDropdownField does not function correctly when using in elemental. Selecting a value does not visually update the field, though when you save the value is saved. I tested using an autoscaffolded field, meaning I had over 100 DataObject which I create via requireDefaultFields(). When setting ->setIsClearable(true) on DBForeignKey.php, when I clicked the clear button I got console warnings (I had run yarn dev in admin)

Discovered when implementing silverstripe/silverstripe-framework#11273

Note this isn't an issue when using a SearchableDropdownField in a regular form

Test setup:

You'll need dnadesign/silverstripe-elemental installed

MyBlock.php

<?php

use DNADesign\Elemental\Models\BaseElement;

class MyBlock extends BaseElement
{
    private static $db = [
        'MyField' => 'Varchar',
    ];

    private static $has_one = [
        'MySubDataObject' => MySubDataObject::class,
    ];
    private static $table_name = 'MyBlock';

    private static $singular_name = 'My Block';

    private static $plural_name = 'My Blocks';

    private static $description = 'This is my block';

    private static $icon = 'font-icon-block-content';

    public function getType()
    {
        return 'My Block';
    }
}

MySubDataObject.php

<?php

use SilverStripe\ORM\DataObject;

class MySubDataObject extends DataObject
{
    private static $table_name = 'MySubDataObject';

    private static $db = [
        'Title' => 'Varchar'
    ];

    private static $has_many = [
        'MyBlock' => MyBlock::class,
    ];

    public function requireDefaultRecords()
    {
        parent::requireDefaultRecords();
        if (self::get()->count() < 110) {
            for ($i = 0; $i < 110; $i++) {
                $record = self::create();
                $record->Title = 'MySubDataObject ' . $i;
                $record->write();
            }
        }
    }
}

New issues created

Shared CI run

PRs

@GuySartorelli
Copy link
Member

PRs merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants