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
Table Generate() creating td with all values as attributes within td tag #1374
Comments
Confirmed on 2.1 & development branch; Pull request above. |
This is not a bug, see the documentation on how to use the Table library: http://codeigniter.com/user_guide/libraries/table.html |
The documentation on the Table class does not cover how to manipulate data from a database resultset before it is rendered. (e.g. take a field with an id and turn it into a checkbox containing that id). This question has been asked several times on the forums and the ones I found came up with the same solution:
The example I listed to reproduce is a simplified version of the following code: from the model:
from the controller:
The above worked in 1.72 but has the logged issue above in the new version. If this is not a bug, then what is the correct action to take when database results need changing before rendering? |
The Table library can't possibly know what your idea or database design is, it doesn't even know that you're using a database. In the example that you've shown, you just need to change this line:
... to this:
|
it doesn't even know that you're using a database. I disagree as there is a function meant to handle database results: Also, the Table documentation gives an example on how to generate a table from a query. It has to understand on some level that the information is coming from a database. Regardless of the above argument, it does not apply to me. I did not state (nor imply) the Table Library should understand my database design; only that I needed to manipulate the results before render. In 1.72 the solution was a lot cleaner than what you prescribe now. |
There might be a method that tries to transform a database result set into a table row, but |
Copied from here
If you take the latest version of CI and replace the welcome controller with the following code:
The table html will render this way:
Notice the first td contains all the elements of the array and should not belong.
The problem is in ../system/libraries/Table.php in function _prep_args around line 183.
What's happening is that the values for the array are getting appended to the array passed. I assume it should replace the array passed.
I was able to fix by making the following code change:
My part is ret_args (stands for "return arguments").
The text was updated successfully, but these errors were encountered: