Welcome Guest, Not a member yet? Register   Sign In
Unable to use typed variables in a cell
#4

(This post was last modified: 05-30-2024, 04:28 AM by Fabio-Zeus-Soft.)

(05-29-2024, 04:00 AM)Bosborne Wrote: How are you passing the variable to the view?

As you can read here, those are made available automatically to the view file, because I'm using controlled cells

(05-29-2024, 05:42 AM)InsiteFX Wrote: View Cells must return a string not an int.

As far as I can see, the Cell is returning a string, because it's returning the content of just_a_test.php.
But for the sake of the conversation, here is the modified version, returning the same error, which is:
Code:
Undefined variable $typedVariable

Code:
JustATestCell.php
PHP Code:
<?php

namespace App\Cells;

use 
CodeIgniter\View\Cells\Cell;

class 
JustATestCell extends Cell
{
    public string $typedVariable;


Code:
just_a_test.php
PHP Code:
<div>
    <?= $typedVariable?>
</div> 
Code:
main view file
PHP Code:
<?=    view_cell('JustATestCell', [
            'typedVariable' => 'test'
        ]);
    ?>
Reply


Messages In This Thread
RE: Unable to use typed variables in a cell - by Fabio-Zeus-Soft - 05-30-2024, 04:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB