Reputation: 87
I have a 3 pages: A, B, and C. I have written a code in Laravel to pass value from A to B from database dude. In which title of A is passed when user clicked the link button in A to B form. But i want to implement the condition where passed variable is displayed in the form of B when user goes through A and display input box when go through page C.
This is the code that links page B from page A:
<a href="{{ URL::action('Bcontroller@show',['title' => $dude->title]) }}" title="B">B</a>
My controller code is:
public function show($title){
return Theme::view("B")->with('title',$title);
}
My B page looks like this:
<input type="title" name="title" value="{{$title}}" placeholder="title" />
My page C html looks like this:
<a href="{{ URL::action('Bcontroller@show') }}" title="C">C</a>
I try to use
@if (isset($title)){
<input type="title" name="title" value="{{$title}}" placeholder="title" />
}@else {
<input type="title" name="title" value="" placeholder="title" />
}
I expect to implement the condition where user can see title in form when it goes through page A and blank form when user go through C.
Upvotes: 0
Views: 53
Reputation: 73
Not sure to well understand the problem, but I think you could use the $_GET['']
attribute to navigate between your pages.
If I didn't get the problem, let me know.
Have fun :)
Upvotes: 0
Reputation: 1176
Not sure what you are trying to do with this logic but you can do what you are asking like this:
These links will take user to page B.
<a href="{{ URL::action('Bcontroller@show',['title' => $dude->title,'page' => 'A']) }}" title="A">A</a>
<a href="{{ URL::action('Bcontroller@show',['title' => $dude->title,'page' => 'C']) }}" title="C">C</a>
I added one more parameter in the URL which you will get at your controller function, you can pass this parameter to your view B.
public function show($title,$page){
return Theme::view("B")->with(compact('title','page'));
}
Based on this parameter value you can show your input text field or whatever.
@if ($page == 'C'){
<input type="title" name="title" value="{{$title}}" placeholder="title" />
}@else {
<input type="title" name="title" value="" placeholder="title" />
}
Upvotes: 1