Xdebug has detected a possible infinite loops, and aborted your script with a stack depth of 256 frames
- Cupara
- Member | 90
@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}
- Infanticide0
- Member | 103
@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
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
@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
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
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
@Cupara
{if $comments->count()}
returned object ($comments) is always evaluated as true.
Last edited by Infanticide0 (2023-12-30 21:55)
- mskocik
- Member | 61
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.”