You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, this is something I came across while creating blocks based on the description in the README file. If you create Blocks/Example.php and Fields/Example.php and both files contain a field with the same name, then one of them overrides the other (I suppose?). And consequently, one of the fields doesn't appear in the editor.
public function fields(): array
{
$example = Builder::make('example'); // <-- this part, if you name it 'example' in both files
$example
->addRepeater('items')
->addText('item')
->endRepeater();
return $example->build();
}
Additionally, if you also create an option page with such a field (Options/Example.php), it will appear on the option page but will completely disappear from both the block and field.
I didn't see any mention that you cannot name fields with the same name, and if this is the case, then I think there should be some kind of warning that something is not right. It took me a while to figure out what was going on; I thought my other code had broken something.
The text was updated successfully, but these errors were encountered:
pkosciak
changed the title
Same names for fields cause fields not appearing in the editor
Using the same names for fields causes the fields not to appear in the editor.
Aug 3, 2024
i think this is an ACF limitation. i will fix the docs to append the type at the end of the names like ExampleOptions and look into maybe throwing an exception in this situation 👍
Hey, this is something I came across while creating blocks based on the description in the README file. If you create Blocks/Example.php and Fields/Example.php and both files contain a field with the same name, then one of them overrides the other (I suppose?). And consequently, one of the fields doesn't appear in the editor.
Additionally, if you also create an option page with such a field (Options/Example.php), it will appear on the option page but will completely disappear from both the block and field.
I didn't see any mention that you cannot name fields with the same name, and if this is the case, then I think there should be some kind of warning that something is not right. It took me a while to figure out what was going on; I thought my other code had broken something.
The text was updated successfully, but these errors were encountered: