@required blade directive #43102
-
Similar to I'm currently defining it like this: Blade::directive('required', function ($expression) {
return "<?php echo ($expression ? 'required' : ''); ?>";
}); It's not that much trouble, but I think it would be a welcome change. I can't figure out where directives are defined in the framework or I would have submitted a pull request for it myself |
Beta Was this translation helpful? Give feedback.
Answered by
erikn69
Jul 8, 2022
Replies: 1 comment 2 replies
-
It should be something like this Blade::directive('required', function ($condition) {
return "<?php if({$condition}): echo 'required'; endif; ?>";
});
/* more generic
@echoif('required', $condition)
@echoif('readonly', $condition)
@echoif('data-value="true"', $condition) */
Blade::directive('echoif', function($arguments){
$args = explode(',', $arguments), 2);
return "<?php if({$args[1]}): e({$args[0]}); endif; ?>";
}); Just put that on your |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
GuidoBelluomo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should be something like this
Just put that on your
ViewServiceProvider