5 months ago

Laravel add variable inside the blade.

Posted 5 months ago by hasandev

i want the javascript confirmation to include the variable name $button_label. Which means that it should have a confirmation of "Save record ?" or "Update record ?".

I'm having a hard time doing it.

Any thoughts?

@php $button_label = Route::current()->getName() == 'maintenance.state.edit' ? 'Update record' : 'Save record' ; @endphp
{!! Form::submit($button_label, ['class' => 'btn btn-primary btn-lg', 'onclick' => 'return confirm("Proceed ?")']) !!}

Please sign in or create an account to participate in this conversation.