Xdebug has detected a possible infinite loops, and aborted your script with a stack depth of 256 frames

Cupara
Member | 90
+
0
-

@Infanticide0 thanks, I prefer WYSIWYG editor over markdown as I plan to expand the editor to wrap text and such eventually.

Cupara
Member | 90
+
0
-

@Infanticide0 I have a new issue, I'm trying to get this if condition to work.

Should I be using n:if inside curly brackets or if?

{if $comments}
	<h2>Comments</h2>

	<div class="comments">
		{foreach $comments as $comment}
			<p><b><a href="mailto:{$comment->email}" n:tag-if="$comment->email">{$comment->name}</a></b> said:</p>

			<div>{$comment->content}</div>
		{/foreach}
	</div>
{else}
	<div class="comments">
		<p>No comments yet.</p>
	</div>
{/if}
Cupara
Member | 90
+
0
-

Nevermind, I got it.

Cupara
Member | 90
+
0
-

@Infanticide0 Should my private function commentFormSucceeded(\stdClass $data): void be a protected function or public function?

Last edited by Cupara (2023-12-29 08:22)

Infanticide0
Member | 103
+
0
-

@Cupara

Use public, just like example in the docs https://doc.nette.org/…in-presenter#…

private or protected won't work because Nette needs to call this function when the form is submitted and validated. If you use protected/private, you get MemberAccessException with message Call to protected method App\Presenters\xyPresenter::onSuccess() from scope Nette\Forms\Form.

Last edited by Infanticide0 (2023-12-29 17:01)

Marek Bartoš
Nette Blogger | 1261
+
+2
-

private or protected won't work

That's not exactly correct. Function that is called in Nette\Forms\Form class and is not defined in it, in one of its parents or in child class must be public.

If you extend Nette\Forms\Form and define function in the child class, function may be also protected.

If you wrap your method in anonymous function, private will also work. That's exactly what first class callables do and therefore, you may use $form->onSuccess[] = $this->commentFormSucceeded(...); with a private function

Cupara
Member | 90
+
0
-

@Infanticide0 and @MarekBartoš thanks for the input from both of you guys.

My next issue is that I'm getting the error Declaration of Contributte\FormsBootstrap\Traits\BootstrapContainerTrait::addDate(string $name, string $label): Contributte\FormsBootstrap\Inputs\DateInput must be compatible with Nette\Forms\Container::addDate(string $name, $label = null): Nette\Forms\Controls\DateTimeControl but I'm not using addDate anywhere in the form I'm using. Is there something else I should look at for this error?

Last edited by Cupara (2023-12-30 05:21)

mskocik
Member | 61
+
0
-

That's because BootstrapContainer extends Nette\Forms\Container and Contributte\Forms package would need to reflect newly added DateTimeControl to Nette\Forms.

The only quick solution is to downgrade Nette\Forms below v3.1.13 where these controls were added.

Cupara
Member | 90
+
0
-

@mskocik what's the long solution?

Cupara
Member | 90
+
0
-

Weird, anytime I use BootstrapForm is when I get the error but if I use just Form it works fine.

Cupara
Member | 90
+
0
-

I'll just use Form with Bootstrap designing.

I think I have my if condition wrong as the else statement isn't working.

{if $comments}
	<div class="comments">
		{foreach $comments as $comment}
			<p><b><a href="mailto:{$comment->email}" n:tag-if="$comment->show_email">{$comment->name}</a></b> said:</p>

			<div>{$comment->content}</div>
		{/foreach}
	</div>
{else}
	<div class="comments">
		<p>No comments yet.</p>
	</div>
{/if}

I think I have the else wrong if someone could inform me of the proper way to do the else in a template I would appreciate it.

Infanticide0
Member | 103
+
0
-

@Cupara

{if $comments->count()}

returned object ($comments) is always evaluated as true.

Last edited by Infanticide0 (2023-12-30 21:55)

Cupara
Member | 90
+
0
-

@Infanticide0 Thanks, appreciate it. Didn't realize I could use $comments->count() to get what I wanted.

mskocik
Member | 61
+
0
-

Cupara wrote:

@mskocik what's the long solution?

As I wrote above – package itself needs to be updated to incorporate this change.

Btw if you want to use bootstrap 5 design for your forms, you can use https://github.com/…orm-renderer package:

Bootstrap5FormRenderer is prepared for every Bootstrap5's form feature like floating labels, input groups (greatly enhanced), validation and everything around it. It supports two independent and easily setupable grids for making custom layouts.”