Support the ongoing development of Laravel.io →
posted 9 years ago
Views
Last updated 2 years ago.
0

I'm curious why you need to throw exceptions in your views and not in a controller/repository/before you render a view?

Last updated 2 years ago.
0

yeah man, your views rendered you returned the request already. take care of the preprocessing in your functions. if your wanting to do something on the page use javascript...

Last updated 2 years ago.
0

I'm not throwing exceptions directly in views but in methods from a class that extends Laravel's Form class. Example:

<?php

class MyFormBuilder extends Illuminate\Html\FormBuilder
    public function numeric($name, $value = null)
    {
        if ($value = 123) {
        	throw new \ExampleException();
        }
        
        return self::input('text', $name, $value, ['class' => 'numeric']);
    }
}
Last updated 2 years ago.
0

Could code like if ($value = 123) be moved elsewhere? It looks like it should go in some sort of validation layer instead of being baked into the template building methods.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.