In this lesson, let's see how easy it is to work with other form fields.
Prepare DB
We need to prepare the DB quickly before adding other fields to the form.
dabatase/migrations/xxxx_add_radio_and_checkbox_select_to_products_table.php:
Schema::table('products', function (Blueprint $table) { $table->string('color'); $table->boolean('in_stock')->default(true);});
app/Models/Product.php:
class Product extends Model{ protected $fillable = [ 'name', 'description', 'category_id', 'color', 'in_stock', ]; const COLOR_LIST = [ 'red' => 'Red', 'green' => 'Green', 'blue' => 'Blue', ]; // ...}
We will use COLOR_LIST
cons to quickly show colors in the form.
Add Fields to Livewire Form
Now let's show...