DEV Community

Cover image for Conditional Input Fields in Livewire: This or That but Never Both

Conditional Input Fields in Livewire: This or That but Never Both

Kennedy Gitahi on March 06, 2024

Have you ever had two conflicting pieces of data that you want to collect using the same form? OK, let me back up. I am building a car bazaar websi...
Collapse
 
dimitrim profile image
Dimitri Mostrey

The conditional radio will work. Extracting the table fields in their own properties is the correct way as well. Your proposal is elegant and easy to read/maintain. The other way is with actions, which is sometimes an overkill.

It seems your code is not 'LiveWire saveable' because there is no validation. I guess you probably know that. Hence the title of your post.

Collapse
 
kengitahi profile image
Kennedy Gitahi

Yes, I did not add the validation because the focus was on the input functionality. Perhaps I should have noted the validation when mentioning saving the data to the database