From 78c0aa437fddc70ffb1c0b076d9ec8d5ec104800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Llu=C3=ADs?= Date: Fri, 31 Aug 2018 17:16:27 +0200 Subject: [PATCH] NEW optional param to show a specific extrafield Using params in showOptionals you can show only a specific extrafield in a personalized form or canvas. For example: print $object->showOptionals($extrafields, 'view', array('onlykey'=>'myfield_5')); --- htdocs/core/class/commonobject.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1b9e9c73224..616f45db6ab 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1,11 +1,9 @@ * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel - * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2012 Cedric Salvador @@ -13,8 +11,9 @@ * Copyright (C) 2016 Bahfir abbes * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017 Nicolas ZABOURI - * Copyright (C) 2017 Rui Strecht + * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018 Frederic France + * Copyright (C) 2018 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -6147,6 +6146,9 @@ abstract class CommonObject $e = 0; foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label) { + //Show only the key field in params + if (is_array($params) && array_key_exists('onlykey',$params) && $key != $params['onlykey']) continue; + $enabled = 1; if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key])) {