⚠ 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 is an archived forum. ⚠

  •     

profile picture

set field_type (readonly) only edit page



Sinnawat Vorasitthipat

Sinnawat Vorasitthipat
  • profile picture
  • Member

Posted 04 September 2013 - 04:03 AM

Sorry for my english.

 

I use this function =>

field_type
$crud->field_type('email','readonly');

I think it should set readonly just only edit page but it also set in add page too and that field that I set it disappear on add page.

 

how to set only edit page but not set in add page ?

 

thank you.


davidoster

davidoster
  • profile picture
  • Member

Posted 04 September 2013 - 08:29 AM

field_type function is a general function that changes the field on add and edit forms.

If you need to change a field only on edit page then you need to use the callback_edit_field and modify it as required.


Sinnawat Vorasitthipat

Sinnawat Vorasitthipat
  • profile picture
  • Member

Posted 04 September 2013 - 08:33 AM

field_type function is a general function that changes the field on add and edit forms.

If you need to change a field only on edit page then you need to use the callback_edit_field and modify it as required.

 

OK Thankyou. I used this instead

$state = $crud->getState();
if($state == "edit")
		{
			$crud->field_type('email','readonly');
			$crud->field_type('activation_key','readonly');
			$crud->field_type('recovery_code','readonly');
			$crud->field_type('datetime_update','readonly');
			$crud->field_type('datetime_delete','readonly');
			$crud->field_type('datetime_create','readonly');
			$crud->field_type('last_login','readonly');

			$crud->unset_fields('status', 'notification_amount', 'password');
		}

It's right way?


davidoster

davidoster
  • profile picture
  • Member

Posted 04 September 2013 - 08:54 AM

Yeap. That's another way of doing it! Well done!