@@ -813,9 +813,6 @@ public function showForm($ID, $options = [])
813813
814814 public static function showForTabContainer ($ c_id , $ item )
815815 {
816- /** @var array $CFG_GLPI */
817- global $ CFG_GLPI ;
818-
819816 //profile restriction
820817 $ right = PluginFieldsProfile::getRightOnContainer ($ _SESSION ['glpiactiveprofile ' ]['id ' ], $ c_id );
821818 if ($ right < READ ) {
@@ -826,22 +823,16 @@ public static function showForTabContainer($c_id, $item)
826823 //get fields for this container
827824 $ field_obj = new self ();
828825 $ fields = $ field_obj ->find (['plugin_fields_containers_id ' => $ c_id , 'is_active ' => 1 ], 'ranking ' );
829- echo "<form method='POST' action=' " . $ CFG_GLPI ['root_doc ' ] . "/plugins/fields/front/container.form.php'> " ;
830- echo Html::hidden ('plugin_fields_containers_id ' , ['value ' => $ c_id ]);
831- echo Html::hidden ('items_id ' , ['value ' => $ item ->getID ()]);
832- echo Html::hidden ('itemtype ' , ['value ' => $ item ->getType ()]);
833- echo "<table class='tab_cadre_fixe'> " ;
834- echo self ::prepareHtmlFields ($ fields , $ item , $ canedit );
835-
836- if ($ canedit ) {
837- echo "<tr><td class='tab_bg_2 center' colspan='4'> " ;
838- echo "<input class='btn btn-primary' type='submit' name='update_fields_values' value= \"" .
839- _sx ('button ' , 'Save ' ) . "\" class='submit'> " ;
840- echo '</td></tr> ' ;
841- }
826+ $ html_fields = self ::prepareHtmlFields ($ fields , $ item , $ canedit );
827+
828+ //display fields as tab container
829+ TemplateRenderer::getInstance ()->display ('@fields/forms/tab_container.html.twig ' , [
830+ 'canedit ' => $ canedit ,
831+ 'html_fields ' => $ html_fields ,
832+ 'item ' => $ item ,
833+ 'c_id ' => $ c_id ,
834+ ]);
842835
843- echo '</table> ' ;
844- Html::closeForm ();
845836
846837 return true ;
847838 }
@@ -960,30 +951,25 @@ public static function showForTab($params)
960951 return ;
961952 }
962953
954+ $ class = match (true ) {
955+ !($ item instanceof CommonITILObject) && $ item instanceof CommonDropdown => 'card-body row ' ,
956+ // @phpstan-ignore-next-line -> Instanceof between CommonDBTM and CommonDropdown will always evaluate to false.
957+ !($ item instanceof CommonITILObject) && !($ item instanceof CommonDropdown) => 'card-body d-flex flex-wrap ' , // lign 969
958+ default => '' ,
959+ };
963960 $ html_id = 'plugin_fields_container_ ' . mt_rand ();
964- if (str_contains ($ current_url , 'helpdesk.public.php ' )) {
965- echo "<div id=' {$ html_id }' class='card-body row mx-0' style='border-top:0'> " ;
966- echo "<div class='offset-md-1 col-md-8 col-xxl-6'> " ;
967- $ field_options = [
968- 'label_class ' => 'col-lg-3 ' ,
969- 'input_class ' => 'col-lg-9 ' ,
970- ];
971- } else {
972- echo "<div id=' {$ html_id }'> " ;
973- }
961+
962+ echo "<div id=' {$ html_id }' class=' " . $ class . "'> " ;
974963 $ display_condition = new PluginFieldsContainerDisplayCondition ();
975964 if ($ display_condition ->computeDisplayContainer ($ item , $ c_id )) {
976965 self ::showDomContainer (
977966 $ c_id ,
978967 $ item ,
979968 $ type ,
980969 $ subtype ,
981- $ field_options ?? [],
970+ [],
982971 );
983972 }
984- if (str_contains ($ current_url , 'helpdesk.public.php ' )) {
985- echo '</div> ' ;
986- }
987973 echo '</div> ' ;
988974
989975 //JS to trigger any change and check if container need to be display or not
@@ -1085,6 +1071,7 @@ public static function prepareHtmlFields(
10851071 $ massiveaction = false ,
10861072 $ field_options = []
10871073 ) {
1074+
10881075 if (empty ($ fields )) {
10891076 return false ;
10901077 }
0 commit comments