3939use Glpi \Form \Condition \ConditionData ;
4040use Glpi \Form \Condition \EditorManager ;
4141use Glpi \Form \Condition \FormData ;
42+ use Glpi \Form \Condition \QuestionData ;
4243use Glpi \Form \Condition \Type ;
4344use Glpi \Form \Question ;
4445use InvalidArgumentException ;
@@ -90,24 +91,21 @@ public function validationEditor(Request $request): Response
9091 );
9192 }
9293
93- // Get the question by UUID
94- $ question = Question::getByUuid ($ form_data ->getSelectedItemUuid ());
95- if ($ question === null ) {
96- throw new NotFoundHttpException (
97- sprintf (
98- 'Question with UUID "%s" not found. ' ,
99- $ form_data ->getSelectedItemUuid ()
100- )
101- );
102- }
94+ // Retrieve the question data
95+ $ question_uuid = $ form_data ->getSelectedItemUuid ();
96+ $ question_name = current (array_filter (
97+ $ form_data ->getQuestionsData (),
98+ fn (QuestionData $ question ) => $ question ->getUuid () === $ question_uuid
99+ ))->getName ();
103100
101+ // Retrieve the conditions data
104102 $ conditions = $ form_data ->getConditionsData ();
105103 $ default_value_operator = current (array_keys ($ this ->editor_manager ->getValueOperatorForValidationDropdownValues (
106- $ question -> fields [ ' uuid ' ]
104+ $ question_uuid
107105 )));
108106 if (empty ($ conditions )) {
109107 $ conditions [] = new ConditionData (
110- item_uuid: $ question -> fields [ ' uuid ' ] ,
108+ item_uuid: $ question_uuid ,
111109 item_type: Type::QUESTION ->value ,
112110 value_operator: $ default_value_operator ,
113111 value: null ,
@@ -118,15 +116,16 @@ public function validationEditor(Request $request): Response
118116 $ last_index = count ($ conditions ) - 1 ;
119117 if (empty ($ conditions [$ last_index ]->getItemUuid ())) {
120118 $ conditions [$ last_index ] = new ConditionData (
121- item_uuid: $ question -> fields [ ' uuid ' ] ,
119+ item_uuid: $ question_uuid ,
122120 item_type: Type::QUESTION ->value ,
123121 value_operator: $ default_value_operator ,
124122 value: null ,
125123 );
126124 }
127125
128126 return $ this ->render ('pages/admin/form/conditional_validation_editor.html.twig ' , [
129- 'question ' => $ question ,
127+ 'question_uuid ' => $ question_uuid ,
128+ 'question_name ' => $ question_name ,
130129 'manager ' => $ this ->editor_manager ,
131130 'defined_conditions ' => $ conditions ,
132131 'items_values ' => $ this ->editor_manager ->getItemsDropdownValues (),
0 commit comments