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

FormFieldExtension bug prevents chaining of methods #8

Open
mikenuguid opened this issue Dec 8, 2019 · 4 comments
Open

FormFieldExtension bug prevents chaining of methods #8

mikenuguid opened this issue Dec 8, 2019 · 4 comments

Comments

@mikenuguid
Copy link

@colintucker, there's a bug on the setter methods in FormFieldExtension where instead of returning the owner class, it's instead returning the extension class thereby returning an error if it's chained with other methods.

The issue won't occur if the setter is the last method in the chain or an instance is created. It's a simple fix and I can create a PR once you agreed. Cheers.

@wernerkrauss
Copy link

Same here.

    $dateField = DateField::create('ProjectDate', 'Datum')
        ->setCalendarConfig($flatpickrCalendarConfig);

    $fields->insertAfter('Excerpt', $dateField);

throws an error:

[Emergency] Uncaught Error: Call to undefined method SilverWare\Calendar\Extensions\FormFieldExtension::getName()

Not chaining works:

    $dateField = DateField::create('ProjectDate', 'Datum');
    $dateField->setCalendarConfig($flatpickrCalendarConfig);

    $fields->insertAfter('Excerpt', $dateField)

Is there any reason that setCalendarConfig returns the extension instead of the form field?

By the way: thanks for that great module!

@mikenuguid
Copy link
Author

@wernerkrauss it's because setCalendarConfig method belongs to the Extension class. So when it returns $this it returns the Extension class instead of DateField class. It should return $this->owner instead in order to return the DateField.

@mikenuguid
Copy link
Author

@colintucker, when you have the time could you please have a look at this issue. Thanks!

@mikenuguid
Copy link
Author

@colintucker, just following up on this issue. Thanks!

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