@@ -61,6 +61,7 @@ public function index(): DataResponse {
6161 * @param string $initialVisibility Initial visibility applied to new values
6262 * @param int $sortOrder Display order used in admin and profile forms
6363 * @param bool $active Whether the definition is currently active
64+ * @param list<string> $options Allowed values for select fields (ignored for other types)
6465 * @return DataResponse<Http::STATUS_CREATED, ProfileFieldsDefinition, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{message: string}, array{}>
6566 *
6667 * 201: Field definition created successfully
@@ -77,9 +78,10 @@ public function create(
7778 string $ initialVisibility = 'private ' ,
7879 int $ sortOrder = 0 ,
7980 bool $ active = true ,
81+ array $ options = [],
8082 ): DataResponse {
8183 try {
82- $ definition = $ this -> fieldDefinitionService -> create ( [
84+ $ payload = [
8385 'field_key ' => $ fieldKey ,
8486 'label ' => $ label ,
8587 'type ' => $ type ,
@@ -89,7 +91,11 @@ public function create(
8991 'initial_visibility ' => $ initialVisibility ,
9092 'sort_order ' => $ sortOrder ,
9193 'active ' => $ active ,
92- ]);
94+ ];
95+ if ($ options !== []) {
96+ $ payload ['options ' ] = $ options ;
97+ }
98+ $ definition = $ this ->fieldDefinitionService ->create ($ payload );
9399
94100 return new DataResponse ($ definition ->jsonSerialize (), Http::STATUS_CREATED );
95101 } catch (InvalidArgumentException $ exception ) {
@@ -111,6 +117,7 @@ public function create(
111117 * @param string $initialVisibility Initial visibility applied to new values
112118 * @param int $sortOrder Display order used in admin and profile forms
113119 * @param bool $active Whether the definition is currently active
120+ * @param list<string> $options Allowed values for select fields (ignored for other types)
114121 * @return DataResponse<Http::STATUS_OK, ProfileFieldsDefinition, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
115122 *
116123 * 200: Field definition updated successfully
@@ -128,14 +135,15 @@ public function update(
128135 string $ initialVisibility = 'private ' ,
129136 int $ sortOrder = 0 ,
130137 bool $ active = true ,
138+ array $ options = [],
131139 ): DataResponse {
132140 $ existing = $ this ->fieldDefinitionService ->findById ($ id );
133141 if ($ existing === null ) {
134142 return new DataResponse (['message ' => 'Field definition not found ' ], Http::STATUS_NOT_FOUND );
135143 }
136144
137145 try {
138- $ definition = $ this -> fieldDefinitionService -> update ( $ existing , [
146+ $ payload = [
139147 'label ' => $ label ,
140148 'type ' => $ type ,
141149 'admin_only ' => $ adminOnly ,
@@ -144,7 +152,11 @@ public function update(
144152 'initial_visibility ' => $ initialVisibility ,
145153 'sort_order ' => $ sortOrder ,
146154 'active ' => $ active ,
147- ]);
155+ ];
156+ if ($ options !== []) {
157+ $ payload ['options ' ] = $ options ;
158+ }
159+ $ definition = $ this ->fieldDefinitionService ->update ($ existing , $ payload );
148160
149161 return new DataResponse ($ definition ->jsonSerialize (), Http::STATUS_OK );
150162 } catch (InvalidArgumentException $ exception ) {
0 commit comments