Skip to content

How to show validation to custom blade columns? #1500

Discussion options

You must be logged in to vote

Hello! I tried a few things and I think I got a good result:

->add('productRemark', function ($row) {
     $error = isset($this->getErrorBag()->getMessages()['productRemark.'.$dish->id])
        ? $this->getErrorBag()->getMessages()['productRemark.'.$dish->id][0]
        : null;

       return Blade::render('<x-editable :id="'.$row->id.'" errors="'.$error.'" />');
})

x-editable

@props([
    'id' => null,
    'errors' => null
])
<div>
    <input wire:model="productRemark.{{ $id }}" type="text" class="form-control"
        placeholder="Enter Product Remark">
    @if($errors)
        <div class="text-red-800">
            {!! $errors !!}
        </div>
    @endif
</div>

Result:

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
5 replies
@abhaypithadiya
Comment options

@marineusde
Comment options

@abhaypithadiya
Comment options

@marineusde
Comment options

@abhaypithadiya
Comment options

Comment options

You must be logged in to vote
2 replies
@luanfreitasdev
Comment options

Answer selected by luanfreitasdev
@abhaypithadiya
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants