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

V8: True/False property value always seems to be false #6252

Closed
sulmbrant opened this issue Aug 31, 2019 · 10 comments
Closed

V8: True/False property value always seems to be false #6252

sulmbrant opened this issue Aug 31, 2019 · 10 comments

Comments

@sulmbrant
Copy link

When using the True/False property in Umbraco 8.1.3 the value seems to always be false no matter if you set it to true.

@kjac
Copy link
Contributor

kjac commented Aug 31, 2019

Sounds strange! @sulmbrant could you please add some steps to reproduce this?

@sulmbrant
Copy link
Author

Nothing strange made.

  1. Added true/false property to composition, set it default to true.
  2. Added composition to doctype
  3. Get the value in view, value is false even if default set to true.
  4. Tried to rebuild models in models builder.
  5. Value still false.
  6. Tried to republish every page.
  7. Value still false.
  8. Set default value to false, tried false (of course)
  9. Change property to true on page, save and publish.
  10. Value still false

@kjac
Copy link
Contributor

kjac commented Aug 31, 2019

Sounds an awful lot like #5224 which was closed due to lack of reproduction ... can you try the solution in #5224 and report back here?

@stevemegson
Copy link
Contributor

I was able to reproduce this, but when I started to investigate the problem went away. I had no composition, just a true/false property directly on the document type. It wasn't saving a false value, it was creating no row at all in umbracoPropertyData for that property, and the missing value was then being converted to false.

I'll see if I can work out how to consistently reproduce it.

@stevemegson
Copy link
Contributor

I don't think this is specific to Checkbox properties.

  • Open a document, and open its document type from the Info tab.
  • Add a property, creating a new data type. (I don't think it happens if you reuse a data type)
  • Enter a value for the new property and save the document.
  • In the request to Content/PostSave, the new property has "value": "", ignoring the value you set.

The Checkbox type does have the added problem that the default value doesn't apply to existing documents until the document is saved. Since there's no row in umbracoPropertyData yet, the value defaults to null and the PropertyValueConverter converts this to false. It would be easy to convert null values to the default value instead, though this could give unexpected behaviour if the default value is later changed. There would be no way for an editor to tell whether a document has a null value which will change to the new default, or has a saved value which matches the default.

@nul800sebastiaan
Copy link
Member

So, if I understand this correctly, this is the case when you edit your doctype and publish document with the newly added property on it?

@nul800sebastiaan
Copy link
Member

Or is this ONLY the case when you add a new property and do not republish the pages which contain the new property?

@nul800sebastiaan nul800sebastiaan added the state/needs-more-info We don't have enough information to give a good reply label Sep 3, 2019
@stevemegson
Copy link
Contributor

There are two separate issues, I think.

When you add a Checkbox property, existing pages will ignore the default value. They'll default to false until you save them, when the editor will respect the default value. This is fairly easy to change, though it has some side effects if the default value is ever changed.

The second issue happens when you add any new property by opening the document type from a document (or maybe only when you also create a new data type for the new property). The new property won't be saved on the document that you already had open. The new property appears, but saving the page will send a blank value for the property. It looks like the model on the new property editor doesn't get properly wired up to the existing model for the rest of the form, but I'll admit it doesn't take much for me to get way out of my depth with angular. Reloading the page is enough to get things behaving again.

@DanielOor365
Copy link

I can confirm the second scenario:
I created a partial - a document type without a template, called "Robots info".
I added 2 NEW properties: "Checkbox - Default TRUE", and made them mandatory.
I then added the properties to EVERY document that has a template.
Result:
The values were only TRUE on those pages that I explicitly PUBLISHED again.
Before publishing: values returned FALSE. After publishing: values returned their correct value.
Conclusion:
Workaround is to publish every single page in Content.
Correct solution would be to make sure de default values of new editors are published, just as they are for reused editors.

@nul800sebastiaan
Copy link
Member

Looks like the described behavior in the initial issue can't be reproduced. The reproduction of the other issues is something that we are aware of and currently don't plan to work on. We are hoping to have a new system in place at some point were default values can be set on all datatypes where it makes sense.

So for the reasons stated in the comments on related issue #8418 (comment) I will close this for now.

@nul800sebastiaan nul800sebastiaan removed the state/needs-more-info We don't have enough information to give a good reply label Jul 13, 2020
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

5 participants