⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


Ana Letícia

Member Since 29 Apr 2014
Offline Last Active May 13 2014 07:25 PM
-----

Topics I've Started

How to custom field on form view

29 April 2014 - 06:08 PM

Hi Everyone, I hope  you  understand me

 

So  I  have  a table about News and I change a column "publicate"(enum : y/n) with display_as "Status"(enum: Yes/No). It works on add form  and  edit form,  but  on view form it is showing "Status"(enum:y/n).  I've tried to use callback_field,callback_column and doesn't work. Someone can help me?

 

Here is my code:

 

$crud->set_table('ibdfam_noticias')
            ->set_subject('Notícias do IBDFAM')
            ->columns('titulo','publicar','destaque','fonte')
            ->display_as('publicar', 'Status')
            ->display_as('hora', 'Data')
            ->fields('titulo','texto','publicar','tags','hora','fonte','destaque','image','creditos','tipo')
            ->field_type('publicar','dropdown',array('s' => 'Ativo', 'n' => 'Inativo'))
            ->field_type('destaque','dropdown',array(0 => 'Não', 1 => 'Sim'))
            ->callback_column('publicar',array($this,'_status'));

 

    public function _status($value, $row)
    {
        
        if($value == 's'){
            $value = 'Ativo';
         }elseif($value =='n'){
            $value =  'Inativo';
         }
        return $value;
    }