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

Latte pass RecursiveComponentIterator instead of original value #194

Closed
MartkCz opened this issue Aug 5, 2019 · 2 comments
Closed

Latte pass RecursiveComponentIterator instead of original value #194

MartkCz opened this issue Aug 5, 2019 · 2 comments

Comments

@MartkCz
Copy link
Contributor

@MartkCz MartkCz commented Aug 5, 2019

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

@dg dg pinned this issue Aug 5, 2019
@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Sep 13, 2019

Can you try if this helps? 276c390

@MartkCz

This comment has been minimized.

Copy link
Contributor Author

@MartkCz MartkCz commented Sep 17, 2019

Probably yes (updated to master and without Exception)

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.