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'));
This commit is contained in:
Josep Lluís 2018-08-31 17:16:27 +02:00 committed by GitHub
parent 7b1a705be4
commit 78c0aa437f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
@ -15,6 +13,7 @@
* Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com> * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* Copyright (C) 2018 Frederic France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -6147,6 +6146,9 @@ abstract class CommonObject
$e = 0; $e = 0;
foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label) 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; $enabled = 1;
if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key])) if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key]))
{ {