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

[4.x] Add localizable toggle to edit field stack #9974

Closed
wants to merge 2 commits into from
Closed

[4.x] Add localizable toggle to edit field stack #9974

wants to merge 2 commits into from

Conversation

robdekort
Copy link
Contributor

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 set localizable to true. This should help.

@sjclark
Copy link
Contributor

sjclark commented Apr 30, 2024

My hero 🥂
I'm an "often user"

@@ -190,6 +190,13 @@ protected function blueprint($blueprint)
'default' => 'visible',
'type' => 'select',
],
'localizable' => [
Copy link
Member

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).

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

cms/src/Sites/Sites.php

Lines 36 to 39 in 897803d

public function hasMultiple()
{
return $this->sites->count() > 1;
}

Copy link
Member

@duncanmcclean duncanmcclean Apr 30, 2024

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.

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.

Copy link
Contributor Author

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 :-).

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

Successfully merging this pull request may close these issues.

4 participants