Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Fuel block params

edited March 2019 in Bug Reports

I'm not sure if this is a bug or misuse, but here's my issue:

Inside a controller Reservations, I'm using a view inside of the email class message() method like so

$content = $this->load->view('reservations/reservation_response_email', ['data' => $data], TRUE);

In that view I'm using fuel_block() to pull in some partials and parse any braced variables (provided above by $data). So that works as intended just fine, but I get a PHP error too:

<br />A PHP Error was encountered

Severity: 4096

Message: Object of class Reservations could not be converted to string

Filename: libraries/Parser.php

Line Number: 150


File: /var/www/public/fuel/modules/fuel/libraries/Fuel_blocks.php
Line: 273
Function: parse_string

File: /var/www/public/fuel/modules/fuel/helpers/fuel_helper.php
Line: 98
Function: render

File: /var/www/public/fuel/application/views/reservations/reservation_response_email.php
Line: 18
Function: fuel_block

File: /var/www/public/fuel/modules/fuel/core/Loader.php
Line: 396
Function: include

File: /var/www/public/fuel/modules/fuel/core/Loader.php
Line: 323
Function: _ci_load

File: /var/www/public/fuel/application/controllers/Reservations.php
Line: 177
Function: view

File: /var/www/public/index.php
Line: 364
Function: require_once

The fuel_block is being used so:

fuel_block(['parse' => TRUE, 'view' => 'reservation_request_'.$data['request']], $data, FALSE);

I need to send parameters to fuel_block(), as if I don't specify parse => TRUE it won't parse the braced variables, while if I just set the first argument to fuel_block() as the view name, I don't get the error.

Somehow the Parser helper or class is referencing the controller class ($this) but I don't know what I need to do to prevent that? I can suppress the error with @fuel_block() of course, but that makes me feel bad.

Sign In or Register to comment.