Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Undefined property on lazyloaded model

In my views I pass a Group model which has many Filters. Each filter has a property part.

Looping over the Filters in volt and printing them results in a undefined property notice.

{% for filter in group.filters %}
    {{ filter.part }}
{% endfor %}

Undefined property: Phalcon\Filter::$part

Obviously this namespace is wrong and should be UniqueLoneDog\Models\Filter Dumping the model with {{ dump(filter) }} shows that it has the correct namespace however.

Anybody know what is going on or why this is happening?

  public 'groupId' => string '18' (length=2)
  public 'type' => string 'predicate' (length=9)
  public 'part' => string 'test' (length=4)


Found the issue.

Solution: Rename filter to groupFilter to prevent name collision.

Filter is also a class which is registerd in the DI. When the volt compiler finds a variable it first looks if it exists in the DI. If it exists the code is compiled to $this->filter->part instead of $filter->part, calling Phalcon\Filter instead of my namespace.