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

Field to be sorted #153

Open
rpostolov opened this issue Oct 7, 2014 · 2 comments
Open

Field to be sorted #153

rpostolov opened this issue Oct 7, 2014 · 2 comments

Comments

@rpostolov
Copy link

Hi,

I have a simple question, i search for the solution but i couldn't find an answer.

I have a field which is a list of countries, but its not sorted. I want to know if it's possible to add an sort option in the generator.yml and if it's yes how.

Here is a part of my admin-generator.yml file

fields:      
      country:
        label: Country
        addFormOptions:
         required: true

Thanks :)

@sescandell
Copy link
Member

Hi @rpostolov

This issue should be created into the AdmingeneratorGeneratorBundle... But let's give you an answer there:

In your [Edit|New]FormType generated file, you can add/customize form options. I think so there you should write your own QueryBuilder. Something like this:

protected function getFormOption($name, array $formOptions)
    {
        if ('country' === $name) {
                $formOptions['query_builder'] = function (CountryRepository $countryRepository){
                    return $countryRepository->getFindQueryBuilderOrderedByName();
                };
            }
        }

        return $formOptions;
    }

By the way, do you know Symfony provides such a form (maybe out of your context): http://symfony.com/fr/doc/current/reference/forms/types/country.html

Hoping that helps,

@rpostolov
Copy link
Author

Hi @sescandell,

Thank you for the answer, i will try this today.

Sorry, i thought that it's belong to Avocode, my bad.

Have a nice day !

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