1

I have the following configuration on my config.yml

ci_api:
    file:
        purposes:
            attachment:

And my configuration class looks like this:

    $treeBuilder = new TreeBuilder();
    $rootNode = $treeBuilder->root('ci_api');

    $rootNode
        ->children()
            ->arrayNode('file')
                ->children()
                    ->arrayNode('purposes')
                        ->children()

                        ->end()
                    ->end()
                ->end()
            ->end()
        ->end(); //children

    return $treeBuilder;

When i tried to run this it gets an error saying:

Unrecognized option "attachment" under "ci_api.file.purposes"

Note that under purposes there can be indefinite number of children.

Thanks.

3
  • 1
    try adding ->prototype('array') before last children() Commented Mar 10, 2017 at 8:59
  • yeah, it did worked .Thanks. Commented Mar 10, 2017 at 10:13
  • I post the comment as an answer so you can close the question Commented Mar 10, 2017 at 10:32

1 Answer 1

1

Simply add the prototype definition as array on the last element definition as follow:

$rootNode
    ->children()
        ->arrayNode('file')
            ->children()
                ->arrayNode('purposes')
                    ->prototype('array')  // Add this line
                    ->children()

                    ->end()
                ->end()
            ->end()
        ->end()
    ->end(); //children
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.