Reputation: 75
I fetch a result in Fat Free Framework with this:
$product = new DB\SQL\Mapper($db,'products');
$product->load(array('productId=:ID',':ID'=>$productId));
Then I walk through $product using the dry() method and do some calculations to some of it's fields. I want to make the re-calculated content of the $product available in my template, so I do:
$f3->set('product_contents', $product);
Now, when in my template I do:
<repeat group ="{{@product_contents}}" value="{{@item}}">
<p>{{@item.productName}}</p>
</repeat>
I get this error:
Internal Server Error
Illegal string offset 'productName'
I discovered that my {{@product_contents}} is a mapper object and not an array, hence the error.
The question is: how can I still use the contents of $product in my template in repeat groups?
Upvotes: 0
Views: 457
Reputation: 41
Just load the result into a variable
$output = $product->load(array('productId=:ID',':ID'=>$productId));
$f3->set('product_contents', $output);
Upvotes: 0