Maxim Bureac
Maxim Bureac

Reputation: 17

dynamically load views partials laravel

Hello I have an issue when it comes to display my creating product form.

The main problem is that i have some fields different from one category to other and i want to display it just with what is needed for a specific category so what i thought is how i can load a partial based on select list.

The workflow is:

  1. I am selecting the product type

  2. I am selecting category

  3. The form partial is displayed.

Yes i could have done this with jquery hiding and toggling classes with fadeIn and fadeOut but is there a way how this could be performed from the laravel part ?

Upvotes: 0

Views: 757

Answers (1)

Kreshnik Hasanaj
Kreshnik Hasanaj

Reputation: 5005

Well you could use ajax calls to load the proper partials for a specific category.

public function controllerMethod()
{
  if (Request::ajax())
  {
     $partial = Request::input('selected_category_partial_name');

     // The foldr stucture would have to be /views/partials/category/name.blade.php
     return view("partials.category.$partial");
  }      
}

Upvotes: 2

Related Questions