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

BUG fieldNameError() references invalid $this->form #9905

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

christopherdarling
Copy link
Contributor

FieldList references $this->form which doesn't exist from what I can see. I presume this should have been $field->getForm().

However, please note that I came across this when looking for something unrelated and haven't tested this PR.

FieldList references `$this->form` which doesn't exist from what I can see. I presume this should have been `$field->getForm()`.

However, please note that I came across this when looking for something unrelated and haven't tested this PR.
@GuySartorelli
Copy link
Member

There definitely isn't a $this->form but there also isn't a getForm() method... I think some more thought needs to go into what's actually happening here. We may not even need this part of the code, but if we do, we need to rethink what it's meant to do exactly and whether we even want a reference to the form a fieldlist belongs to.

@kinglozzer
Copy link
Member

There definitely isn't a $this->form but there also isn't a getForm() method

There is on FormField:

/**
* Get the currently used form.
*
* @return Form
*/
public function getForm()
{
return $this->form;
}

This is just to include the form name in the “I noticed a field name X appears twice” error message, I just tested this patch and it seems to work fine:

[Emergency] Uncaught RuntimeException: SilverStripe\Forms\{closure}() I noticed that a field called 'Title' appears twice in your 'SilverStripe\Forms\Form' form called 'SearchForm'

@GuySartorelli
Copy link
Member

Ahhh yup I didn't notice $this was swapped out for $field.

@GuySartorelli GuySartorelli merged commit 3e85c4d into silverstripe:4 Jul 7, 2022
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

Successfully merging this pull request may close these issues.

3 participants