Hi,
You cannot use a isEmpty() method on Input::get(). But Laravel has something very handy to solve your problem...
if( Input::has('submit_more') )
{
// Redirect to route A
}
Hope this will help...
When I do this, the if statements aren't working. The page doesn't redirect.
Ok.
Can you just post the PHP code block with your if statements and the HTML form so I could have a better look of the situation?
Also, when you say that the page isn't redirecting, do you see an error message or is it something else?
Sure thing. Here is the form:
<form action="{{ URL::route('add-save') }}" method="post" class="form_content">
<div class="row">
<div class="large-3 columns"><label for="song_title" class="right inline">Song Title</label></div>
<div class="large-9 columns end"><input type="text" name="song_title" id="song_title"></div>
</div>
<hr>
<div class="row">
<div class="large-9 large-offset-3 columns">
<p><button type="submit" name="submit_more" class="button">Save & Add Another to This Group<i class="fa fa-arrow-circle-right"></i></button><br>
<button type="submit" name="submit_title" class="button">Save & Add Alt. Titles<i class="fa fa-plus-circle"></i></button><br>
<button type="submit" name="submit_group" class="button">Save & Add a New Group<i class="fa fa-plus-circle"></i></button><br>
<a href="{{ URL::route('show-main', $group->show_id) }}" class="button">Finish <i class="fa fa-times-circle"></i></a></p>
</div>
</div>
{{ Form::token() }}
</form>
NOTE: I don't like FormBuilder. I feel that I have more control over the form if I do it old-school.
And here are the if statements in the controller:
if(Input::has('submit_more'))
{
return Redirect::route('show-song-add3', array('id' => Input::get('id')));
}
if(Input::has('submit_title'))
{
return Redirect::route('show-song-title-add', array('id' => $song_id));
}
if(Input::has('submit_group'))
{
return Redirect::route('show-song-add1', array('id' => Input::get('show_id')));
}
I appreciate the help.
Found it!
You just have to add a fake value to your button ( value="Foo" ) because Input::has() don't only checks if your form element exists but also checks if the element has some value...
<button type="submit" name="submit_more" class="button" value="Foo">Save & Add Another to This Group<i class="fa fa-arrow-circle-right"></i></button>
<br>
<button type="submit" name="submit_title" class="button" value="Foo">Save & Add Alt. Titles<i class="fa fa-plus-circle"></i></button>
<br>
<button type="submit" name="submit_group" class="button" value="Foo">Save & Add a New Group<i class="fa fa-plus-circle"></i></button>
Hope it will help you...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community