This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi everyone,
In a page, I try to do something like this :
<?php use Project\Object\Models\Thing;
function onStart(){
$this['trucs'] = Thing::where('foo', '=', 'bar')->paginate(5);
}
?> [...] {% for truc in trucs%}
<div class="col-sm-8">
{{ truc.name }}
<form data-request="onUpdate"
data-request-validate
data-request-flash>
{% component 'trucform' %}
</div>
{% enfor %}
trucform is a component, a form where I need {{ truc.name }} for value tag for example.
In fact, we can see the first {{ truc.name }} twig but all the others in the compent doesn't work. If the {% for ... %} is suppressed, and $this['trucs'] = Thing::where('foo', '=', 'bar')->paginate(5) is replaced by $this['trucs'] = Thing::where('foo', '=', 'bar')->first(), it works...
Help me Obi-Wan Kenobi, you're my last hope...
I'm not sure to clearly understand what you mean, but maybe you need to explicitly pass your truc variable to your component. Something like that :
{% component 'trucform' truc = truc %}
1-2 of 2