Viewing 3 reply threads
  • Author
    Posts
    • #2638
      catacaly
      Member

      I had two separate non-hierarchical taxonomies for Manufacturers and Models but decided to make them one single instead of forging a relationship between them as separate taxonomies altogether…

      So now I have them in one, make_model taxonomy, and eventually intend to get rid of their default UI, once I have a custom working alternative; because for one thing I only want them to be 1 level deep, that is, excluding the top level — so that top level would be Manufacturers, and the first sub-level would be Models per, and go no deeper. I don’t know how to set a maximum.

      First what I need to do is create a meta box in my CPT edit screen, with a select field for Manufacturer, and then a Model field that shows conditionally if any manufacturer is selected, its children, allowing for a selection to be made finally of the Model.

      Another thing is that I need a default null value for both of these fields in question. The Model is to be a required field, and for one to be selected, a Manufacturer must be selected, so just the first one cannot be selected by default; default must be no selected value, and upon changing the value of the Manufacturer, the value of the Model should reset to null as well.

      Here’s my manufacturer field:

      
      piklist('field', array(
        'type' => 'select'
        ,'scope' => 'taxonomy'
        ,'field' => 'manufacturer'
        ,'label' => 'Manufacturer'
        ,'choices' => piklist(
            get_terms('make_model', array(
              'hide_empty' => false
              ,'parent' => 0
            ))
            ,array(
              'term_id'
              ,'name'
            )
        )
      ));

      Model I figured would somehow go something like this:

      
      piklist('field', array(
        'type' => 'select'
        ,'scope' => 'taxonomy'
        ,'field' => 'model'
        ,'label' => 'Model'
        ,'choices' => piklist(
            get_terms('make_model', array(
              'hide_empty' => false
              //,'child_of' => 
            ))
            ,array(
              'term_id'
              ,'name'
            )
        )
      ));

      utilizing the conditions parameters somehow like here https://piklist.com/user-guide/docs/fields/field-parameters/conditions/ except I don’t quite see how I can tie it all together.

      Ideas?

      Thanks.

    • #2639
      catacaly
      Member

      Is there a way to pass the child terms to update the reliant model field with choices? instead of just a value?

    • #2640
      catacaly
      Member

      The master field has got to switch what it updates the conditional field with depending on its own value… which has to be a variable self referenced?

    • #2647
      Steve
      Keymaster

      @catacaly– The Piklist conditions system cannot do this yet. You would need to save the first field, pull the value and then display the second field.

Viewing 3 reply threads
  • The topic ‘Manufacturer/Model terms relationship/selection’ is closed to new replies.