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

RFC fields inside a set inside a collection can't be named "name" #1111

Open
eduardomart opened this issue Sep 27, 2020 · 3 comments
Open

RFC fields inside a set inside a collection can't be named "name" #1111

eduardomart opened this issue Sep 27, 2020 · 3 comments

Comments

@eduardomart
Copy link
Contributor

eduardomart commented Sep 27, 2020

I believe this is related to: #1025

sidebar:
    ...
    fields:
        socialnetworks:
            label: "Social Networks"
            type: collection
            fields:
                socialnetwork:   # <----------------- this is always the output of 'name'
                    type: set
                    label: Social Network
                    fields:
                        name:        # <------------------ this can't be accessed, unless it's renamed to something else
                            label: Name
                            type: text
                        icon:
                            label: Icon
                            type: text
                        link:
                            label: Link
                            type: text
            group: content
   ...
  singleton: true

And you try to iterate the 'socialnetworks':

{% set content sn = 'contenttype' %}

{% for item in sn.socialnetworks %}
   {{ item.name }}
{% endfo%}

you will always get "socialnetwork" output in each iteration, however if you rename the text field "name" to something different like "title" then you get the actual value of the text field.

I think this needs to be clarified still in the docs, or maybe make a note that "name" shouldn't be used inside collection fields...

@I-Valchev
Copy link
Member

Yesss! Essentially all the getter methods in the Field entity cannot be used as names for fields. Let's update the docs on that.

@eduardomart
Copy link
Contributor Author

@I-Valchev but this would only be the case for fields within collections, correct? because it seems regular fields can use the name name so I don't know if this might lead to confusion for users.

@I-Valchev
Copy link
Member

Yes, you are right!

Essentially:
If there's a getX method in Content.php -> x cannot be the name of a field.
If there's a getY method in Field.php (and all methods from field classes) -> y cannot be the name of a field inside a collection/set.

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

2 participants