Skip to content

Form containers with numeric nameย #396

@spaze

Description

@spaze

First, I know that form containers may not be fully supported yet, see #380, but this may or may not be directly related so I'm still filing this.

I have a form with multiple containers (they're nested but that's unrelated I think)

This is how I build the containers, notice the for loop and addContainer($i):

		$disclosureNewContainer = $disclosureContainer->addContainer('new');
		for ($i = 0; $i < $newDisclosures; $i++) {
			$disclosureNewCountContainer = $disclosureNewContainer->addContainer($i);

In a template:

	{formContainer new}
		{formContainer $i}  <-- line 85

This is how it's compiled by the extension:

             /* line 84 */
            $this->global->formsStack[] = $formContainer = $form['new'];
            /* line 85 */
            $this->global->formsStack[] = $formContainer = \Nette\Bridges\FormsLatte\Runtime::item($i, $this->global);

I get this error on level 5:

 ------ ---------- ---------------------------------------------------------------------------------------------------------------------------------------------
  Line   Compiled   Admin/Presenters/templates/Pulse/passwordsStorages.latte rendered from MichalSpacekCz\Admin\Presenters\PulsePresenter::passwordsStorages
         line       See compiled template: /tmp/phpstan-latte/app/Admin/Presenters/templates/Pulse/passwordsStorages.latte.8f4b78add10adffe699f7ad521d7e14e.php
 ------ ---------- ---------------------------------------------------------------------------------------------------------------------------------------------
  85     437        Parameter #1 $item of static method Nette\Bridges\FormsLatte\Runtime::item() expects object|string, int<0, 2> given.
 ------ ---------- ---------------------------------------------------------------------------------------------------------------------------------------------

I'm not sure where object|string is coming from, because \Nette\Bridges\FormsLatte\Runtime::item($item, $global): object doesn't use any type declarations at all: https://github.com/nette/forms/blob/8a23250f05443cae8b7c8294003c3f2a9d38ffc5/src/Bridges/FormsLatte/Runtime.php#L115

And eventually does this

return $form[$item];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions