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

StringFieldSettings DefaultValue not working #1919

Open
Neutrino-Sunset opened this issue Aug 3, 2022 · 1 comment
Open

StringFieldSettings DefaultValue not working #1919

Neutrino-Sunset opened this issue Aug 3, 2022 · 1 comment

Comments

@Neutrino-Sunset
Copy link

Create a trivial custom block, do not define a block component attribute so that in the manager adding the block displays the fields. Add this field to the block.

[StringFieldSettings(DefaultValue="Some Value")]
public StringField SomeField { get; set; }

The default value is not displayed in the manager when adding the block to a page, nor is the default value applied to the field when the block is rendered in the page in preview.

Attempting to create a workaround using the following.

public void InitManager()
{
   if (SomeStringField.Value == null)
   {
      SomeStringField = "Some Value";
   }
}

The default value is not dispayed in the editor when the block is first added to the page, but it is displayed after adding it if the page is closed and then reopened in the editor.

So I haven't yet found a workaround for initializing a field with a default value that is shown to the user when the block is added to a page.

@tidyui
Copy link
Member

tidyui commented Aug 24, 2022

I think the default value was actually removed from the implementation at the last minute as there was no way to determine if the field (and model) was actually new, or if the user has deliberately cleared the value of the field. If I remember correctly we removed it to discuss if this behavior was ok, and then it never got added back into the manager.

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