corcel / acf

Advanced Custom Fields (ACF) plugin for Corcel
127 stars 100 forks source link

Fatal error when acf field does not exists at a post. #13

Closed marcoboom closed 7 years ago

marcoboom commented 7 years ago

In AdvancedCustomFields.php the __get functions returns the get() method of the result of FieldFactory::make, but when the custom field not exists for a particuler post, the result of the FieldFactory will be null. So an exception will be thrown.

Better to change the return of the __get() method to:

 return $field ? $field->get() : null;
jgrossi commented 7 years ago

Hey @marcoboom thanks for reporting. Can you send a PR? Thanks!

jgrossi commented 7 years ago

Fixes #14. Thanks!