Search code examples
phpcodeigniterframeworksgrocery-crud

How make multiline fields in GROCERY CRUD?


What do I need to change to make two lines (or more) fields presentation in GROCERY CRUD (CodeIgniter framewoks)?

In examples on site I see table like I need. But I make view and see my table like this example

I have some columns 50-100 characters long, and I need to show all content of them. But now I getting something like My field cont... instead of:

'My field 
content'

Solution

  • If you are using GC version 1.3+, you can change grocery_crud_character_limiter config option to zero:

    //The character limiter at the list page, zero(0) value if you don't want character limiter at your list page
    $config['grocery_crud_character_limiter']   = 30;
    

    in this file:

    application/config/grocery_crud.php

    This is system-wide setting. If you want to affect only some lists, you will have to add some code:

    $crud->callback_column('text_to_show', array($this, '_full_text'));
    
    function _full_text($value, $row)
    {
        return $value = wordwrap($row->text_to_show, 100, "<br>", true);
    }
    

    Credits goes to this page: http://www.grocerycrud.com/forums/topic/339-list-showing-data-row-without-limitation-of-chars/