Reputation: 935
in my blade i have this submit button provided by blade here is my code
{{ Form::submit('Create System User', array('class' => 'btn btn-primary')) }}
i wanted to know if the user clicked the submit button already because i have a code below saying
@if ($errors->any())
<ul>
{{ implode('', $errors->all('<p style="color:red" class="error">:message</p>')) }}
</ul>
@else
<script>
BootstrapDialog.alert('Record Added!');
</script>
@endif
my problem is it keeps displaying the bootstrap alert on load whereas it should only be when the user is successfully created any ideas?
Upvotes: 1
Views: 453
Reputation: 1464
Something along these lines should do the trick:
In your controller method:
public function store()
{
$input = Input::all();
Session::flash('submitted', true);
// Logic to create user
return Redirect::back(); // Or whatever your response is
}
And then in your view:
@if (Session::get('submitted'))
<script>
BootstrapDialog.alert('Record Added!');
</script>
@endif
Upvotes: 1