Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: tfoot_open / tfoot_close have no default when using custom table template #4219

Closed
richard-keasley opened this issue Feb 2, 2021 · 0 comments · Fixed by #4275
Closed
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@richard-keasley
Copy link

richard-keasley commented Feb 2, 2021

description
ErrorException "Undefined index: tfoot_open" is thrown when rendering a table with a footer.

CodeIgniter 4 version
4.1.0

Affected module(s)
File: System/View/Table.php
Function: _compileTemplate()
Line: 500

Expected behavior, and steps to reproduce if appropriate
Use \CodeIgniter\View\Table()
Set a custom template, but omit tfoot_open or tfoot_close
Add something to the table using setFooting()
call generate()

suggested solution

the keys tfoot_open and tfoot_close have been missed from the array on line 501.

Replace

foreach (['table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close'] as $val)
{  
    if (! isset($this->template[$val]))  
    {    
        $this->template[$val] = $temp[$val];  
    }  
}

with

foreach($temp as $key=>$val)  
{  
    if (! isset($this->template[$key]))  
    {  
        $this->template[$key] = $val;  
    }  
}
@richard-keasley richard-keasley added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant