-
-
Notifications
You must be signed in to change notification settings - Fork 547
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
[4.x] Add localizable toggle to edit field stack #9974
Conversation
My hero 🥂 |
@@ -190,6 +190,13 @@ protected function blueprint($blueprint) | |||
'default' => 'visible', | |||
'type' => 'select', | |||
], | |||
'localizable' => [ |
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.
Right now, this config field is showing on all fields, even if you're working on a single-site install or in managing fields in a Grid.
We should probably only be showing this option when the canDefineLocalizable
prop is set to true
(which is what we use to determine if the localizable icon shows or not).
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.
Ahh yeah, great catch. Don't think I can do that from the PHP array can I?
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.
Btw, something to consider. I wouldn't mind always having the globe and this toggle available. I've had quite a few projects where I know it's gonna be multisite some day, but not yet. In those cases I would still like to prepare fields by setting them to localizable or not.
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.
Ahh yeah, great catch. Don't think I can do that from the PHP array can I?
Nope, it'll need to be done in Vue.
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.
An if based on the handle? I could look into later.
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.
You can use the Sites::hasMultiple()
of the Sites Facade to determine if the localizable toggle should be added or not. That's effectively the same thing as the method in Vue.
Lines 36 to 39 in 897803d
public function hasMultiple() | |
{ | |
return $this->sites->count() > 1; | |
} |
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.
Unfortunately, that won't work for nested fields (like Grids and Replicators), where the canDefineLocalizable
is set to false
.
:can-define-localizable="false" |
Ideally, we'd be using the same logic for this new field.
From a quick look at the code, it looks like showing the field based on that prop might be a little involved.
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 have a clue how to do this. Closing this one. If someone else wants to take a stab at it: be my guest :-).
This adds the
localizable
toggle to the edit field stack. Currently it's only available on the fieldset builder overview as a globe icon. Often users can't find out how to setlocalizable
totrue
. This should help.