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

Filter by embed Document #138

Closed
joshlopes opened this issue May 26, 2015 · 2 comments
Closed

Filter by embed Document #138

joshlopes opened this issue May 26, 2015 · 2 comments

Comments

@joshlopes
Copy link
Contributor

I have a document that has the property merchant with the name ("m") and embeds a document with id that referes to a Merchant in simple = true

When i am filtering my field name is always ID -- to fix it i added this:

# Sonata/DoctrineMongoDBAdminBundle/Filter/Filter.php
public function getFieldName()
    {
        $fieldName = $this->getOption('field_name');

        if (!$fieldName) {
            throw new \RuntimeException(sprintf('The option `field_name` must be set for field: `%s`', $this->getName()));
        }

        foreach($this->getOption('parent_association_mappings') as $map) {
            if(!empty($map['name'])) {
                $fieldName = $map['name'] . "." . $fieldName;
            } elseif (!empty($map['fieldName'])) {
                $fieldName = $map['fieldName'] . $fieldName;
            }
        }

        return $fieldName;
    }

Not sure if is the best approach or if is going to break more stuff -- on DataGridBuilder there is a function "fixFieldDescription" , i could set the option field name there but wanted to make sure what is the right approach to this.

@joshlopes
Copy link
Contributor Author

Fixed here: #137

Along with the autocomplete

@joshlopes
Copy link
Contributor Author

This is been fixed on my PR so closing

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

1 participant