Jump to content


How to custom field on form view

callback_column callback_field view hour_format view form

  • Please log in to reply
6 replies to this topic

#1 Ana Letícia

Ana Letícia

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 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;
    }



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 29 April 2014 - 10:27 PM

well there is a function callback_read_field in the gc library - not documented-  u can use that



#3 Ana Letícia

Ana Letícia

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 30 April 2014 - 05:55 PM

Amit,  I didn't  find   this function callback_read_field . Can you be more clear  about  how  to use it?



#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 01 May 2014 - 06:28 AM

this function is available with gc 1.4.1 - believe - check it if you have it.. else i will share you the version of library i have (i have modified it.. with quite a lot of other functionalities to my requirements).



#5 Ana Letícia

Ana Letícia

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 02 May 2014 - 04:40 PM

My  version is 1.4.1 but  it  doesn't work,  do you have it in github? or send  to my  email  ana.leticia.cn@hotmail.com



#6 edramirez

edramirez

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts
  • LocationMetro Manila

Posted 03 June 2014 - 04:50 PM

Hi, Ana -

 

"Calculated values" work correctly in the add and edit modes but don't appear correctly in the view section. This is not limited to your example. Oftentimes I am faced with the question on whether to figure out a solution or eliminate the view section altogether. In my personal experience, I have found it more beneficial to remove the view section and not bother with any additional programming to correct the problem.

 

There are two kinds of geniuses - the first deals with the ability to solve problems and the second deals with eliminating the need to solve a problem. As a developer, you sometimes need to be on or the other. So, don't forget to click the Like button...

 

Regards,

 

Ed Ramirez



#7 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 04 June 2014 - 01:22 PM

hi ana

 

refer to the following url - its same issue.. patch coe given in there!!

http://www.grocerycr...he-read-method/







Also tagged with one or more of these keywords: callback_column, callback_field, view, hour_format, view form

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users