@@ -191,6 +191,22 @@ public static function showForForm(CommonDBTM $item, $withtemplate = '') {
191191 return true ;
192192 }
193193
194+ public function getDesignLabel (): string {
195+ $ questionId = $ this ->getID ();
196+ $ nb = (new DBUtils ())->countElementsInTable (PluginFormcreatorCondition::getTable (), [
197+ 'itemtype ' => PluginFormcreatorQuestion::getType (),
198+ 'items_id ' => $ questionId ,
199+ ]);
200+ $ sectionId = $ this ->fields [PluginFormcreatorSection::getForeignKeyField ()];
201+ $ onclick = 'plugin_formcreator.showQuestionForm( ' . $ sectionId . ', ' . $ questionId . '); ' ;
202+ $ html = '<a href="javascript: ' . $ onclick . '" data-field="name"> ' ;
203+ $ html .= "<sup class='plugin_formcreator_conditions_count' title=' " . __ ('Count of conditions ' , 'formcreator ' ) ."'> $ nb</sup> " ;
204+ $ html .= empty ($ this ->fields ['name ' ]) ? '( ' . $ questionId . ') ' : $ this ->fields ['name ' ];
205+ $ html .= '</a> ' ;
206+
207+ return $ html ;
208+ }
209+
194210 /**
195211 * Get the HTML for the question in form designer
196212 *
@@ -218,16 +234,8 @@ public function getDesignHtml() : string {
218234
219235 // Question name
220236 $ html .= $ field ->getHtmlIcon () . ' ' ;
221- $ onclick = 'plugin_formcreator.showQuestionForm( ' . $ sectionId . ', ' . $ questionId . '); ' ;
222- $ html .= '<a href="javascript: ' . $ onclick . '" data-field="name"> ' ;
223237 // Show count of conditions
224- $ nb = (new DBUtils ())->countElementsInTable (PluginFormcreatorCondition::getTable (), [
225- 'itemtype ' => PluginFormcreatorQuestion::getType (),
226- 'items_id ' => $ this ->getID (),
227- ]);
228- $ html .= "<sup class='plugin_formcreator_conditions_count' title=' " . __ ('Count of conditions ' , 'formcreator ' ) ."'> $ nb</sup> " ;
229- $ html .= empty ($ this ->fields ['name ' ]) ? '( ' . $ questionId . ') ' : $ this ->fields ['name ' ];
230- $ html .= '</a> ' ;
238+ $ html .= $ this ->getDesignLabel ();
231239
232240 // Delete the question
233241 $ html .= "<span class='form_control pointer'> " ;
0 commit comments