Jump to content


Change field as "disabled" when editing row..

edit disabled field change_type

  • Please log in to reply
5 replies to this topic

#1 Charles A.

Charles A.

    Member

  • Members
  • PipPip
  • 17 posts

Posted 16 July 2013 - 10:37 PM

Hi, is there any way to show the values (but like disabled="disabled")... Only when editing.. ?? For example, i have

  • Car_Model (combobox)
  • Car_Color (combobox)
  • Observations (free text)

Following the given example, when I add, i have to complete all the data, but when I edit, I just want to edit OBSERVATIONS and show the MODEL and the COLOR using the combobox but disabled.. (like disabled='disabled' tag)....

 

Is that possible?

 

Thx!



#2 Amit Shah

Amit Shah

    grocery CRUD Master

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

Posted 17 July 2013 - 11:50 AM

There is a trick in this, never tried working on it directly but you surely can

/Here was the trick. Identify if the operation was Unknown / List then redirect it the users 
//profile update page
   $state_code = $crud->getState();
   if($state_code == 'edit') {
        $crud->change_field_type('field1', 'disabled');
   }

Technically this should work.



#3 Charles A.

Charles A.

    Member

  • Members
  • PipPip
  • 17 posts

Posted 20 July 2013 - 07:44 PM

Hi Amit, thanks for your reply! But it doesnt  work at all... 

 

The field i'm trying to disable it's a combobox (retrieving the name from other table with a relation_n) 

 

So, when I apply your code, only shows an input box with the ID (not the name or description) and yes, disabled... 

 

Is there any way to show the text instead the ID ? Car_color.name (YELLOW) instead of Car_color.id (7) for ex ?

 

Thanks!!



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 20 July 2013 - 10:15 PM

I suggest you use the callback_field and you change from there whatever you need.

Or to be more precise callback_edit_field.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 Charles A.

Charles A.

    Member

  • Members
  • PipPip
  • 17 posts

Posted 22 July 2013 - 03:21 AM

Thanks David! I've used callback_edit_field() as you suggested; and inside the callback function I used function from a model to retrieve the information from the database and replace the combobox with an input text (disabled).

 

Thanks!



#6 yoandry

yoandry

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 26 January 2016 - 06:49 PM

$state_code = $crud->getState();
            if($state_code == 'edit') {
                $crud->field_type('field_x', 'readonly');
            }







Also tagged with one or more of these keywords: edit, disabled, field, change_type

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users