devict / votelocal

A web app for receiving local voting information via SMS
15 stars 16 forks source link

Replace form partials with Laravel 7 components #93

Closed imacrayon closed 4 years ago

imacrayon commented 4 years ago

This:

@include('partials/fields/input', [
    'label' => __('Name'),
    'name' => 'name',
    'value' => old('name', $tag->name),
    'class' => 'mt-6',
    'attributes' => [ 'required' => true ],
])

Becomes:

<x-text :label="__('Name')" name="name" :value="old('name', $tag->name)" required />

Cleaner form markup!

Laravel 7 blade components live in resources/views/components, the component tag begins with <x-filename .... Attributes work just like HTML attributes. Prefixing an attribute with a : will allow you to use a PHP expression in the attribute's value.