expose field type object in fields api get items

This commit is contained in:
Leo Germani 2018-04-06 11:40:21 -03:00
parent cc36906eca
commit 9cf0894a5d
1 changed files with 3 additions and 2 deletions

View File

@ -262,14 +262,15 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
public function prepare_item_for_response( $item, $request ) { public function prepare_item_for_response( $item, $request ) {
if(!empty($item)){ if(!empty($item)){
$item_arr = $item->__toArray(); $item_arr = $item->__toArray();
$item_arr['field_type_object'] = $item->get_field_type_object()->__toArray();
if($request['context'] === 'edit'){ if($request['context'] === 'edit'){
$item_arr['current_user_can_edit'] = $item->can_edit(); $item_arr['current_user_can_edit'] = $item->can_edit();
ob_start(); ob_start();
$item->get_field_type_object()->form(); $item->get_field_type_object()->form();
$form = ob_get_clean(); $form = ob_get_clean();
$item_arr['edit_form'] = $form; $item_arr['edit_form'] = $form;
$item_arr['field_type_object'] = $item->get_field_type_object()->__toArray();
$item_arr['enabled'] = $item->get_enabled_for_collection(); $item_arr['enabled'] = $item->get_enabled_for_collection();
} }