I am making a sales support system with Laravel 4. I have a form for recording projects and another for saving sales notes. There I want to enable users to add a new project without having to leave the create sales note form for the new project form. I have a partial for the create project form, which I use in both the normal way of creating a project and the one I use in the create sales note. In the latter case I need to display a cancel button in addition to the submit button, so I intended to pass a parameter to my form partial to tell wether the cancel button is needed or not, like so:
projects/create.blade.php:
@include("partials.NewProjectForm", array("cancel" => "no"))
salesnotes/create.blade.php:
@include("partials.NewProjectForm", array("cancel" => "yes"))
partials/NewProjectForm.blade.php:
@if($cancel == "yes")
{{ Form::button("Cancel") }}
@endif
In the "no" case the partial receives the passed variable as expected, in the "yes" case however it throws the "Undefined variable: cancel" error. I have tried as well including the partial with View::make()->with(), with the same result. Whats going wrong there?
Thanks.