Courses

Livewire 3 From Scratch: Practical Course

Other Form Fields: Radio and Checkbox

Summary of this lesson:
- Adding radio button inputs
- Implementing checkbox functionality

In this lesson, let's see how easy it is to work with other form fields.

radio and checkbox inputs


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...

The full lesson is only for Premium Members.
Want to access all 30 lessons of this course? (108 min read)

You also get:

  • 73 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord