-
Notifications
You must be signed in to change notification settings - Fork 15
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
FIX Console warning about required type #163
FIX Console warning about required type #163
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I haven't tested locally
Should revert the using of string booleans because they're confusing and instead just rely on native Silverstripe behaviour. Seems like the actual bug is coming from the use of types
being an array instead of an object
src/Form/LinkField.php
Outdated
@@ -44,7 +44,7 @@ protected function getDefaultAttributes(): array | |||
{ | |||
$attributes = parent::getDefaultAttributes(); | |||
$attributes['data-value'] = $this->Value(); | |||
$attributes['data-can-create'] = $this->getOwner()->canEdit(); | |||
$attributes['data-can-create'] = $this->getOwner()->canEdit() ? 'true' : 'false'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the use of string booleans here, it gets confusing. Revert this and just do things how Silverstripe does them natively
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/Form/MultiLinkField.php
Outdated
@@ -61,7 +61,7 @@ protected function getDefaultAttributes(): array | |||
{ | |||
$attributes = parent::getDefaultAttributes(); | |||
$attributes['data-value'] = $this->getValueArray(); | |||
$attributes['data-can-create'] = $this->getOwner()->canEdit(); | |||
$attributes['data-can-create'] = $this->getOwner()->canEdit() ? 'true' : 'false'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert so that we're not using string booleans
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -53,8 +53,8 @@ jQuery.entwine('ss', ($) => { | |||
ownerRelation: inputField.data('owner-relation'), | |||
onChange: this.handleChange.bind(this), | |||
isMulti: this.data('is-multi') ?? false, | |||
types: this.data('types') ?? [], | |||
canCreate: this.getInputField().data('can-create') ?? false, | |||
types: this.data('types') ?? {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert so that we're not using string booleans
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave this part with new changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If canEdit()
returns true, then data-can-create
attribute exists and inputField.data('can-create')
= data-can-create
, if canEdit()
returns false, then inputField.data('can-create')
= undefined
. So we can use this in JS to return true
instead of return a string data-can-create
.
f574157
to
23f49e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to rebase to fix merge conflicts
23f49e1
to
f22ce6d
Compare
Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally works good
Description
types
.If$this->getOwner()->canEdit()
returns boolean value, then$attributes['data-can-create']
is populated with'data-can-create'
instead of boolean value. Now return string value.Parent issue