Search code examples
phpcakephphtml-helpermodulus

Using modulus with a cakephp html helper table


I have multiple arrays with an unknow amount of items per array. I want to put the items in a html table with 4 td's per row. Our work is a bit pedantic and want us to use the cakephp helper and I am a bit unsure how I would go about using modulus with the HTML helper or does cake have a way to ensure I only have 4 td's per row before going to the next row?

I am sorry, I really have no idea how to go about this, hence no sample code


Solution

  • If you want to rely on the Helper this won't work with the CakePHP core helper.

    I've written a more powerful helper for tables for CakePHP 2.x.

    Check the test for an example https://github.com/burzum/BzUtils/blob/master/Test/Case/View/Helper/TableHelperTest.php

    You can pass an anonymous function as callback to a row and do your td's there as you need them. You also can change the code directly and make your helper app and case specific but you should not need to do this using my TableHelper.