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

[Parser] Nested Substitutions not working #6190

Closed
Alex-Licea opened this issue Jan 11, 2023 · 2 comments
Closed

[Parser] Nested Substitutions not working #6190

Alex-Licea opened this issue Jan 11, 2023 · 2 comments

Comments

@Alex-Licea
Copy link

Hi everybody:

When I try to run a nested substitution with view parser like the example in the docs view_parser.html#nested-substitutions, CI return an exception:

ErrorException Invalid argument supplied for foreach() SYSTEMPATH/View/Parser.php at line 314

I've used CI version 4.2 and 4.3 and the issue is the same.

The only way to make it works is to change the example $data array from the docs example:

$data = [
    'blog_title'   => 'My Blog Title',
    'blog_heading' => 'My Blog Heading',
    'blog_entry'   => [
        'title' => 'Title 1',
        'body'  => 'Body 1',
    ],
];

To this:

$data = [
      'blog_title'   => 'My Blog Title',
      'blog_heading' => 'My Blog Heading',
      'blog_entry'   => [
            [
                  'title' => 'Title 1',
                  'body'  => 'Title 1',
            ],
    ];

The parser can't handle a single level of values in the array, they need to be contained in array to make it work. This behavior is the right one or the docs are outdated?

Thanks for your support.

@kenjis
Copy link
Contributor

kenjis commented Jan 15, 2023

This is the repository for CodeIgniter3.

But you are correct. The sample code is not correct.
See codeigniter4/CodeIgniter4#7103

@Alex-Licea
Copy link
Author

Oh! I'm sorry, but thank you for your support!

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