You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whats a elegant way to handle select options for dropdowns/select menus?
Since I'm trying to use my EmployeeData for both request and response.
Lets say my EmployeeData has a service property that is a Lazy relation of ServiceData.
ServiceData is a large data class with co relations etc so I don't want to send the whole ServiceData itself as the select option. So on create form I map all available services (ServiceData) into a serviceOptions (OptionData) which is just id, label, value and an optional group.
The issue is when I now submit the form request to create an employee it's still triggering required validation. Even though the service key/value is not sent in the request.
I've had a look through the docs and tried finding other discussions for this. Feel like this is a pretty common use case so maybe I'm just being silly.
class EmployeeData extends Data
public function __construct(
public Lazy|ServiceData $service,
public OptionData|Optional $serviceOption,
)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Whats a elegant way to handle select options for dropdowns/select menus?
Since I'm trying to use my EmployeeData for both request and response.
Lets say my EmployeeData has a service property that is a Lazy relation of ServiceData.
ServiceData is a large data class with co relations etc so I don't want to send the whole ServiceData itself as the select option. So on create form I map all available
services
(ServiceData) into aserviceOptions
(OptionData) which is justid
,label
,value
and an optionalgroup
.The issue is when I now submit the form request to create an employee it's still triggering required validation. Even though the service key/value is not sent in the request.
I've had a look through the docs and tried finding other discussions for this. Feel like this is a pretty common use case so maybe I'm just being silly.
Beta Was this translation helpful? Give feedback.
All reactions