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

Entry Field with Slug "value" Breaks Statamic #2495

Closed
LloydThinks opened this issue Sep 22, 2020 · 6 comments · Fixed by #10462
Closed

Entry Field with Slug "value" Breaks Statamic #2495

LloydThinks opened this issue Sep 22, 2020 · 6 comments · Fixed by #10462

Comments

@LloydThinks
Copy link

Bug Description

Creating the field "Value" with slug "value" breaks something in the Statamic loading pipeline.

How to Reproduce

  1. Create a collection "testing" (name irrelevant)
  2. Create a single Entry in that collection
  3. Edit the blueprint of that collection to include an attribute with the name "Value" and slug "value". (I tested this with two different field types and it broke both times. Can't claim every type, but seems that way.)
  4. Add a {{ collection:testing }}{{ /collection:testing }} Antlers tag to your html
  5. Load that page, which should produce an error.

Extra Detail

Error Produced:

ArgumentCountError
Too few arguments to function Statamic\Entries\Entry::value(), 0 passed in /Users/Hermes/Sites/lloydm/vendor/statamic/cms/src/Data/AbstractAugmented.php on line 53 and exactly 1 expected

Environment

Statamic 3.0.8 Solo
Laravel 6.18.35
PHP 7.4.9
statamic/ssg dev-master

(I cannot update to 3.0.11 because of another issue (#2456) still being worked on)

@duncanmcclean
Copy link
Member

This issue is likely caused by value being a reserved word in Statamic. These are still needing to be documented, there's an issue over here for that. statamic/docs#236

A workaround would be to call the handle of the field something other than value and set Value as the label of the field.

@jasonvarga
Copy link
Member

A field named value doesn't need to be reserved. We can work around it.

@LloydThinks
Copy link
Author

This issue is likely caused by value being a reserved word in Statamic. These are still needing to be documented, there's an issue over here for that. statamic/docs#236

A workaround would be to call the handle of the field something other than value and set Value as the label of the field.

Hey @damcclean thank you for the quick reply. This is what I did, I was just pointing out that at no point in the process does Statamic make this clear to me as a user. If it is reserved, then don't let me set it as a slug. Alternatively, as @jasonvarga replied, if it is NOT reserved, then I believe we need to fix something. Regardless, the issue has a place until one of those two things happens.

Lloyd

@jasonvarga
Copy link
Member

All good, I reopened the issue already.

@jasonvarga
Copy link
Member

Note to self: I think the AugmentedEntry (and AbstractAugmented) class could have a list of proxyable methods rather than just checking everything. e.g. We'd want to proxy slug but not value.

@jasonvarga
Copy link
Member

#3989 will add validation to prevent you from creating a field named value. I'm leaving this open though because I still think a field named value should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants