Skip to content

Latte pass RecursiveComponentIterator instead of original value #194

@MartkCz

Description

@MartkCz

Version: 2.5.2

Works in 2.5.1

{define container $val, $options}
	{var $options = $options ?: new App\UI\Options()}

	<div n:tag-if="$options->getColumns()" class="row">
		{foreach $val as $ctrl}
			<div n:tag-if="$options->getColumns()" n:class="$options->getColumnClass()">
				{if $ctrl instanceof Nette\Forms\Container}
					{include container $ctrl->getComponents(), $ctrl->getOptions()}

				{else}
					{dump $ctrl}
					{include controlContainer $ctrl}

				{/if}
			</div>
		{/foreach}
	</div>

{/define}

{define controlContainer $val}
	{dump $val}
	<div n:if="!$val->getOption(rendered) && $val->getOption(type) !== hidden"
			n:class="form-group, $val->required ? required, $val->error ? has-error"
			n:attr="id => $val->getOption(id)">

		{if $val->getOption(type) === file}
			{php $val->getControlPrototype()->addClass('ctrl-inline')}
			{include control $val}

		{elseif $val->getOption(type) === radio}
			{include radio $val}


		{elseif $val->getOption(type) === checkbox}
			{include checkbox $val}

		{else}
			{include control $val}

		{/if}
	</div>
{/define}

First dump is WebChemistry\Images\Controls\UploadControl (in container), second dump is Nette\ComponentModel\RecursiveComponentIterator (in controlContainer)

Error: Call to undefined method Nette\ComponentModel\RecursiveComponentIterator::getOption()

EDIT

When I dump this latte code:

Tracy\Debugger::barDump(($ctrl), '$ctrl');
bdump([$ctrl] + get_defined_vars());
$this->renderBlock('controlContainer', [$ctrl] + get_defined_vars(), 'html');

dump is https://i.ibb.co/N6jcvj7/image.png

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions