Jump to content

How to subselect in select-field (dynamic)?


August
 Share

Recommended Posts

Hello, I'm getting stuck trying to build a filter between subcategories and some items.

image.png.5c97219dd1290513a4a233ba0b879d3a.png

For the final Item itself, I setup a reference field and wrote following selector:
image.png.9bbdca7163b59f0530ebddcbc0e9c94d.png

If there are more entries, filtering by manufacturer (which is part of the item) would be very helpful.
The problem I'm stuck: How I can get and select an existing manufacturer field, which exist here: fieldset_device.manufactor

I tried a hook, just not happy with the result, I despair on:

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    $page = $event->arguments('page');
    if($event->object->hasField == 'hardware_manfilter') {
        $subcat = $page->hardware_subcategory;
        $items = $event->pages->find("parent=$subcat");
        $event->return = $items->each('fieldset_device.manufactor');
   }
});I

I appreciate any help. 

Link to comment
Share on other sites

If i undertand it correct you just need:

$herstellerfilter="manufactor='Hersteller abc'";
$pages->find("template.name=produkt, parent.name=meine_produkte, $herstellerfilter");
Link to comment
Share on other sites

Thank you @tires, but I'm looking for a solution, that let me directly select the manufactor depending on chosen "hardware_subcategoy". This field has a page field, that hold the info about manufactorrer. I need to divide Articles by manufator, just before select an Arricle from. 
In this case I figured out, that I can change the Label-Field from Title to a custome one:
image.png.7e4a1a541ce940e153524542fe43fccd.png
The result shows stored manufactor to each item, not quit what I'm looking for, but I can see, it's somehow possible reaching the pagefield "manufactor" within a fieldset in my template:
image.png.f6c3dfce8486e24e4520e6e40511ec1b.png
Instead I need first a list of available manufactorer, unique, so then I just can select the prefiltered Articles (item) in the 4th select-field, named "hardware_item". The last custom Selector String for this 4th select(pagefield) should be "parent=page.hardware_manfilter".

Selector String: Something like this does not work:
image.png

In a hook Ive tried only the  These selector, without the subselcet, but here I have to save the page to see some Changes which otherwise are dynamic.

$event->return = $page->hardware_subcategory->children;

I hope my Quest is more clear and I ask again:
      Whats the best way doing it, is it possible?
Thanks in Advance.

 

Link to comment
Share on other sites

  • August changed the title to How to subselect in select-field (dynamic)?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...