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

can't set attributes to fields in elemental #9885

Closed
sunnysideup opened this issue Mar 13, 2021 · 4 comments
Closed

can't set attributes to fields in elemental #9885

sunnysideup opened this issue Mar 13, 2021 · 4 comments

Comments

@sunnysideup
Copy link
Contributor

sunnysideup commented Mar 13, 2021

Affected Version

4.7 + Elemental

Description

The attributes do not seem to be applied to any Elemental Block fields. This is a real shame because it makes the Elemental Block not as pretty as it could be.

Steps to Reproduce

Add the following fields to a page:

        $fields->addFieldsToTab(
            'Root.Links',
            [
                OptionsetField::create('LinkType', 'Link Type', $this->owner->dbObject('LinkType')->enumValues())
                    ->setAttribute('onclick', 'console.log(1)'),
                TextField::create('ExternalLink', 'External Link')
                     ->setAttribute('placeholder', 'test')
            ]
        );

Attributes work fine.

Add them to an Elemental Block and it does not work.

Having onchange available is awesome because you can added conditionals - etc...

@michalkleiner
Copy link
Contributor

Should the issue be better raised with https://github.com/silverstripe/silverstripe-elemental/ module?

@sunnysideup
Copy link
Contributor Author

Should the issue be better raised with https://github.com/silverstripe/silverstripe-elemental/ module?

Sure, my guess is that is a GraphQL conversion issue, rather than an Elemental specific issue.

@kinglozzer
Copy link
Member

Thanks for reporting @sunnysideup, I’m going to close this as we’re tracking it in a couple of places already:

I found a possible workaround until it’s fixed by calling setSchemaData() directly, from memory it was something like this:
$field->setSchemaData(['attributes' => ['placeholder', 'test']])

@micschk
Copy link
Contributor

micschk commented Nov 24, 2021

Temporary workaround (eg for placeholder attribute):
$field->setSchemaData(['attributes' => ['placeholder' => 'My placeholder value']]);

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

No branches or pull requests

4 participants