We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Jason Sonderman Reply #1, 10 years ago
    I need to create a listbox (single select) of options from another table, filtering them by a value from the current MIGXdb.

    Example: My MIGXdb is adding a record to the Products table. I need to choose a color. The Color dropdown is populated by running a snippet to get the entries from the Colors table.

    I don't want ALL the colors, but only the ones assigned to the Product group that the new product belongs to.

    Both the Product record and the Colors records have a "group_id" field that refers to the id of the Product Group table.

    So what I want to do is, in MIGXdb, add form field of listbox type, and for input use this:
    @EVAL return $modx->runSnippet('list.lister', array('line'=>`[[+line_id]]`));
    where the line parameter is set to the grp_id field of Product Group this product is being added to (filtering the color records to only those that belong to this Product Group).

    How do I pass this? Do I need to join the Product Group table, and if so, what is the syntax to pass the id of the joined table record to the @EVAL call?

    This question has been answered by Bruno17. See the first response.

      • 4172
      • 5,888 Posts
      does the colors-listbox need to change dynamically, the same time, when a product-group - listbox does change, or is it enough, when the colors-listbox loads its colors, when opening the form-window?

      Or when/where do they set the group-id for a product?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • Jason Sonderman Reply #3, 10 years ago
        To be simple, we can start with the on window load option. Ideally, yes, it would be great for the color-list box to update if the product group listbox changes, but at minimum I need the color listbox to show only the values that are assigned to the product group that the new product belongs to.

        I posted the schemas for the Product Group and Product Configs on this post:

        This is the db schema for the three tables in question:
        <object class="productLine" table="rli_product_line" extends="xPDOSimpleObject" >
        	<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
        	<field key="priority" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default="100"/>
        	<field key="description" dbtype="mediumtext" phptype="string" null="true" default=""/>
        	<field key="disabled" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        	<field key="video" dbtype="varchar" precision="255" phptype="string" null="true" default=""/>
        	<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        	<field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
        	<field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
        	<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        	<field key="deletedon" dbtype="datetime" phptype="datetime" null="false" />
        	<field key="deletedby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
        	<field key="publishedon" dbtype="datetime" phptype="datetime" null="false" />
        	<field key="publishedby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
        	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
        		<column key="id" collation="A" null="false" />
        	</index>
        </object>
        <object class="productInfo" table="rli_products" extends="xPDOSimpleObject" >
        	<field key="prod_no" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index"/>
        	<field key="options" dbtype="mediumtext" phptype="string" null="true" default=""/>
        	<field key="qty" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default=""/>
        	<field key="so" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default=""/>
        	<field key="so_text" dbtype="varchar" precision="255" phptype="string" null="true" default="" index="index"/>
        	<field key="grp_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
        	<field key="line_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
        	<field key="category" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
        	<field key="colors" dbtype="varchar" precision="255" phptype="string" null="true" default=""/>
        	<field key="priority" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default="100"/>
        	<field key="disabled" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        	<field key="sample" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        	<field key="sample_qty" dbtype="tinyint" precision="4" attributes="unsigned" phptype="integer" null="false" default="0" />
        	<field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
        	<field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
        	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
        		<column key="id" collation="A" null="false" />
        	</index>
        	<aggregate alias="ProductLine" class="productLine" local="line_id" foreign="id" cardinality="one" owner="foreign"/>
        </object>
        <object class="productColorGroups" table="rli_color_groups" extends="xPDOSimpleObject" >
        	<field key="colorgroupname" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
        	<field key="colorgroupvalue" dbtype="mediumtext"  phptype="string" null="false" default="" />
        	<field key="line_id" dbtype="varchar" precision="255" phptype="string" null="true" default=""/>
        	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
        		<column key="id" collation="A" null="false" />
        	</index>
        </object>
          • 4172
          • 5,888 Posts
          I'm unsure, where the colors are coming from. Is there another table for the colors?
          what does the list.lister - snippet do?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
          • Jason Sonderman Reply #5, 10 years ago
            The list.lister snippet is a utility snippet that allow me to build drop downs based on the passed classname. There are some dropdowns that use IDs as values, others that use strings as values depending on the field I want to drop the selected value in.

            For this, it goes and gets all the classes from productColorGroups table, and formats them into Display==value syntax and returns them.

            So now I want the snippet to filter our any records that don't have a line_id field that matches teh parent (productline) id.

            Better way of building dropdowns of records from another Table? I am open. Originally this color field could accept multiple values, but I changed that to now only accept a single id (integer) value per record.
              • 4172
              • 5,888 Posts
              I'm still trying to rebuild the CMP, but seems there are still missing relevant parts of the configs and of the schema.

              Otherwise I need to guess to much and I'm not that good in guessing.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
              • Jason Sonderman Reply #7, 10 years ago
                The overall package has a lot of MIXDB configs, handling various parts of the Product Line manager.
                Posting the Schema is pretty easy, but not sure the best was to send you all the configs.

                  • 4172
                  • 5,888 Posts
                  I think the xpdo-schema should be enough
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                  • Jason Sonderman Reply #9, 10 years ago
                    <?xml version="1.0" encoding="UTF-8"?>
                    <model package="rhythmcatalog" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                    <object class="productLine" table="rli_product_line" extends="xPDOSimpleObject" >
                    	<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                    	<field key="priority" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default="100"/>
                    	<field key="description" dbtype="mediumtext" phptype="string" null="true" default=""/>
                    	<field key="disabled" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<field key="video" dbtype="varchar" precision="255" phptype="string" null="true" default=""/>
                    	<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
                    	<field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
                    	<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<field key="deletedon" dbtype="datetime" phptype="datetime" null="false" />
                    	<field key="deletedby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
                    	<field key="publishedon" dbtype="datetime" phptype="datetime" null="false" />
                    	<field key="publishedby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<composite alias="ProductColorGroup" class="productLineColorGroup" local="id" foreign="line_id" cardinality="many" owner="local"/>
                    </object>
                    <object class="productGroup" table="rli_product_group" extends="xPDOSimpleObject" >
                    	<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                    	<field key="description" dbtype="varchar" precision="255" phptype="string" null="true" default="" />
                    	<field key="line_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
                    	<field key="image_path" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                    	<field key="disabled" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<field key="sample_days" dbtype="tinyint" precision="4" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<aggregate alias="ProductLineColorGroup" class="productLine" local="line_id" foreign="id" cardinality="one" owner="foreign"/>
                    </object>
                    <object class="productInfo" table="rli_products" extends="xPDOSimpleObject" >
                    	<field key="prod_no" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index"/>
                    	<field key="options" dbtype="mediumtext" phptype="string" null="true" default=""/>
                    	<field key="qty" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default=""/>
                    	<field key="so" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default=""/>
                    	<field key="so_text" dbtype="varchar" precision="255" phptype="string" null="true" default="" index="index"/>
                    	<field key="grp_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
                    	<field key="line_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
                    	<field key="category" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    	<field key="colors" dbtype="tinyinteger" attributes="unsigned" phptype="integer" null="true" default=""/>
                    	<field key="priority" dbtype="integer" precision="10" phptype="integer" attributes="unsigned" null="true" default="100"/>
                    	<field key="disabled" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<field key="sample" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<field key="sample_qty" dbtype="tinyint" precision="4" attributes="unsigned" phptype="integer" null="false" default="0" />
                    	<field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
                    	<field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<aggregate alias="ProductLine" class="productLine" local="line_id" foreign="id" cardinality="one" owner="foreign"/>
                    	<aggregate alias="ProductColor" class="productColorGroup" local="colors" foreign="id" cardinality="one" owner="foreign"/>
                    	<aggregate alias="ProductGroup" class="productGroup" local="grp_id" foreign="id" cardinality="one" owner="foreign"/>
                    </object>
                    <object class="productColor" table="rli_colors" extends="xPDOSimpleObject" >
                    	<field key="colorname" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                    	<field key="colorvalue" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
                    	<field key="basevalue" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
                    	<field key="colorgroup" dbtype="integer" precision="1" phptype="integer" attributes="unsigned" null="false" default="0"/>
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    </object>
                    <object class="productColorGroup" table="rli_color_groups" extends="xPDOSimpleObject" >
                    	<field key="colorgroupname" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                    	<field key="colorgroupvalue" dbtype="mediumtext"  phptype="string" null="false" default="" />
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<composite alias="ProductLineColorGroup" class="productLineColorGroup" local="id" foreign="cg_id" cardinality="many" owner="local"/>
                    </object>
                    <object class="productCategory" table="rli_categories" extends="xPDOSimpleObject" >
                    	<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                    	<field key="value" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
                    	<field key="description" dbtype="varchar" precision="255" phptype="string" null="true" default="" />
                    	<field key="line_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<aggregate alias="ProductLine" class="productLine" local="line_id" foreign="id" cardinality="one" owner="foreign"/>
                    </object>
                    <object class="productLineColorGroup" table="rli_line_cg_opts" extends="xPDOSimpleObject" >
                    	<field key="cg_id" dbtype="tinyint" phptype="integer" attributes="unsigned" null="false" default="0"/>
                    	<field key="line_id" dbtype="tinyint" phptype="integer" attributes="unsigned" null="false" default="0" />
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<aggregate alias="ProductLine" class="productLine" local="line_id" foreign="id" cardinality="one" owner="foreign"/>
                    	<aggregate alias="ProductColorGroup" class="productColorGroup" local="cg_id" foreign="id" cardinality="one" owner="foreign"/>
                    </object>
                    <object class="productLineOptions" table="rli_product_line_opts" extends="xPDOSimpleObject" >
                    	<field key="line_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
                    	<field key="opt_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<aggregate alias="ProductLine" class="productLine" local="line_id" foreign="id" cardinality="one" owner="foreign"/>
                    	<aggregate alias="ProductOption" class="productColorGroups" local="opt_id" foreign="id" cardinality="one" owner="foreign"/>
                    </object>	
                    
                    <object class="customProduct" table="rli_custom_products" extends="xPDOSimpleObject" >
                    	<field key="pkg_id" dbtype="integer" precision="5" phptype="integer" attributes="unsigned" null="false" default=""/>
                    	<field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    	<field key="description" dbtype="mediumtext" phptype="string" null="false" default=""/>
                    	<field key="colors" dbtype="mediumtext" phptype="string" null="false" default=""/>
                    	<field key="options" dbtype="mediumtext" phptype="string" null="true" default=""/>
                    	<field key="qty" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0"/>
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    	<aggregate alias="CustomKit" class="customKit" local="pkg_id" foreign="id" cardinality="one" owner="foreign"/>
                    </object>	
                    <object class="customKit" table="rli_custom_kits" extends="xPDOSimpleObject" >
                    	<field key="pkg_name" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    	<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    		<column key="id" collation="A" null="false" />
                    	</index>
                    </object>	
                    </model>


                    This is a cleaned up version from earlier this morning.
                    • discuss.answer
                      • 4172
                      • 5,888 Posts
                      OK, here's my setup for you.

                      create two files:

                      core/components/rhythmcatalog/migxconfigs/Products.config.inc.php
                      <?php
                      
                      $object_id = $this->modx->getOption('object_id',$_REQUEST,0);
                      //let us get only products, which belong to the current productline
                      $this->customconfigs['getlistwhere']='{"line_id":"'.$object_id.'"}';
                      


                      core/components/rhythmcatalog/processors/mgr/products/fields.php

                      <?php
                      
                      $config = $modx->migx->customconfigs;
                      $prefix = isset($config['prefix']) && !empty($config['prefix']) ? $config['prefix'] : null;
                      $object_id = 'new';
                      
                      if (isset($config['use_custom_prefix']) && !empty($config['use_custom_prefix'])) {
                          $prefix = isset($config['prefix']) ? $config['prefix'] : '';
                      }
                      $packageName = $config['packageName'];
                      $sender = 'default/fields';
                      
                      $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
                      $modelpath = $packagepath . 'model/';
                      if (is_dir($modelpath)){
                          $modx->addPackage($packageName, $modelpath, $prefix);
                      }
                      $classname = $config['classname'];
                      
                      $joinalias = isset($config['join_alias']) ? $config['join_alias'] : '';
                      
                      $joins = isset($config['joins']) && !empty($config['joins']) ? $modx->fromJson($config['joins']) : false;
                      
                      if (!empty($joinalias)) {
                          if ($fkMeta = $modx->getFKDefinition($classname, $joinalias)) {
                              $joinclass = $fkMeta['class'];
                          } else {
                              $joinalias = '';
                          }
                      }
                      
                      if ($this->modx->lexicon) {
                          $this->modx->lexicon->load($packageName . ':default');
                      }
                      
                      $line_id = $modx->getOption('co_id',$scriptProperties,0);
                      
                      if (empty($scriptProperties['object_id']) || $scriptProperties['object_id'] == 'new') {
                          if ($object = $modx->newObject($classname)){
                              $object->set('object_id', 'new');
                              //set current line-id, if new product
                              $object->set('line_id',$line_id);
                          }
                          
                      } else {
                          $c = $modx->newQuery($classname, $scriptProperties['object_id']);
                          $pk = $modx->getPK($classname);
                          $c->select('
                              `' . $classname . '`.*,
                          	`' . $classname . '`.`' . $pk . '` AS `object_id`
                          ');
                          if (!empty($joinalias)) {
                              $c->leftjoin($joinclass, $joinalias);
                              $c->select($modx->getSelectColumns($joinclass, $joinalias, 'Joined_'));
                          }
                          if ($joins) {
                              $modx->migx->prepareJoins($classname, $joins, $c);
                          }
                          if ($object = $modx->getObject($classname, $c)){
                              $object_id = $object->get('id');
                          }
                      }
                      
                      $_SESSION['migxWorkingObjectid'] = $object_id;
                      
                      //handle json fields
                      if ($object){
                          $record = $object->toArray();
                      }
                      else{
                          $record = array();
                      }
                      
                      
                      foreach ($record as $field => $fieldvalue) {
                          if (!empty($fieldvalue) && is_array($fieldvalue)) {
                              foreach ($fieldvalue as $key => $value) {
                                  $record[$field . '.' . $key] = $value;
                              }
                          }
                      }
                      
                      



                      Install http://modx.com/extras/package/dynamicdropdowntv

                      create three dynamicdropdown TVs:

                      1.
                      name: productlines
                      Dynamic Dropdown Group: rli_products

                      2.
                      name: productgroups
                      Parent Dropdown: productlines
                      Dynamic Dropdown Group: rli_products

                      3.
                      name: colorgroups
                      Parent Dropdown: productgroups
                      Dynamic Dropdown Group: rli_products

                      and three files:

                      core/components/dynamicdropdowntv/processors/mgr/rli_products/getoptions.productlines.php
                      <?php
                      
                      $query = $modx->getOption('query', $scriptProperties, '');
                      
                      $tv = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['tvname']));
                      $inputProperties = $tv->get('input_properties');
                      
                      $modx->lexicon->load('tv_widget', 'dynamicdropdowntv:inputoptions');
                      $lang = $modx->lexicon->fetch('dynamicdropdowntv.', TRUE);
                      
                      $firstText = $modx->getOption('firstText', $inputProperties, $lang['firstText_default'], TRUE);
                      
                      $packageName = 'rhythmcatalog';
                      $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
                      $modelpath = $packagepath . 'model/';
                      $modx->addPackage($packageName, $modelpath);
                      
                      $classname = 'productLine';
                      $c = $modx->newQuery($classname);
                      
                      $options = array();
                      $count = 1;
                      
                      if (!empty($query)) {
                      	$c->where(array('name:LIKE' => $query . '%'));
                      } else {
                      	$options[] = array('id' => '', 'name' => $firstText);
                      }
                      
                      //$c->where(array('parent' => '0'));
                      
                      //$c->prepare();echo $c->toSql();
                      if ($collection = $modx->getCollection($classname, $c)) {
                      	$count += $modx->getCount($classname);
                      	foreach ($collection as $object) {
                      		$option['id'] = $object->get('id');
                      		$option['name'] = $object->get('name');
                      		$rows[strtolower($option['name'])] = $option;
                      	}
                      	ksort($rows);
                      
                      	foreach ($rows as $option) {
                      		$options[] = $option;
                      	}
                      }
                      
                      return $this->outputArray($options, $count);
                      
                      


                      core/components/dynamicdropdowntv/processors/mgr/rli_products/getoptions.productgroups.php
                      <?php
                      
                      $query = $modx->getOption('query', $scriptProperties, '');
                      $line_id = $modx->getOption('productlines',$scriptProperties,0);
                      
                      $tv = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['tvname']));
                      $inputProperties = $tv->get('input_properties');
                      
                      $modx->lexicon->load('tv_widget', 'dynamicdropdowntv:inputoptions');
                      $lang = $modx->lexicon->fetch('dynamicdropdowntv.', TRUE);
                      
                      $firstText = $modx->getOption('firstText', $inputProperties, $lang['firstText_default'], TRUE);
                      
                      $packageName = 'rhythmcatalog';
                      $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
                      $modelpath = $packagepath . 'model/';
                      $modx->addPackage($packageName, $modelpath);
                      
                      $classname = 'productGroup';
                      $c = $modx->newQuery($classname);
                      
                      $options = array();
                      $count = 1;
                      
                      if (!empty($query)) {
                      	$c->where(array('name:LIKE' => $query . '%'));
                      } else {
                      	$options[] = array('id' => '', 'name' => $firstText);
                      }
                      
                      $c->where(array('line_id' => $line_id));
                      
                      //$c->prepare();echo $c->toSql();
                      if ($collection = $modx->getCollection($classname, $c)) {
                      	$count += $modx->getCount($classname);
                      	foreach ($collection as $object) {
                      		$option['id'] = $object->get('id');
                      		$option['name'] = $object->get('name');
                      		$rows[strtolower($option['name'])] = $option;
                      	}
                      	ksort($rows);
                      
                      	foreach ($rows as $option) {
                      		$options[] = $option;
                      	}
                      }
                      
                      return $this->outputArray($options, $count);
                      
                      


                      core/components/dynamicdropdowntv/processors/mgr/rli_products/getoptions.colorgroups.php
                      <?php
                       
                      //@EVAL return $modx->runSnippet('list.lister', array('useid'=>'1', 'class'=>'productColorGroups','nameField'=>'colorgroupname')); 
                       
                      $query = $modx->getOption('query', $scriptProperties, '');
                      $group_id = $modx->getOption('productgroups',$scriptProperties,0);
                      $line_id = $modx->getOption('productlines',$scriptProperties,0);
                      
                      $tv = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['tvname']));
                      $inputProperties = $tv->get('input_properties');
                      
                      $modx->lexicon->load('tv_widget', 'dynamicdropdowntv:inputoptions');
                      $lang = $modx->lexicon->fetch('dynamicdropdowntv.', TRUE);
                      
                      $firstText = $modx->getOption('firstText', $inputProperties, $lang['firstText_default'], TRUE);
                      
                      $packageName = 'rhythmcatalog';
                      $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
                      $modelpath = $packagepath . 'model/';
                      $modx->addPackage($packageName, $modelpath);
                      
                      $classname = 'productColorGroup';//here I'm not sure which class you want select from, 
                      $c = $modx->newQuery($classname);
                      
                      //may be you will need to join here to some other table, needs to be figured out
                      
                      $options = array();
                      $count = 1;
                      
                      if (!empty($query)) {
                      	$c->where(array('colorgroupname:LIKE' => $query . '%'));
                      } else {
                      	$options[] = array('id' => '', 'name' => $firstText);
                      }
                      
                      $c->where(array('cg_id' => $group_id));//this needs to be figured out
                      
                      //$c->prepare();echo $c->toSql();
                      if ($collection = $modx->getCollection($classname, $c)) {
                      	$count += $modx->getCount($classname);
                      	foreach ($collection as $object) {
                      		$option['id'] = $object->get('id');
                      		$option['name'] = $object->get('colorgroupname');
                      		$rows[strtolower($option['name'])] = $option;
                      	}
                      	ksort($rows);
                      
                      	foreach ($rows as $option) {
                      		$options[] = $option;
                      	}
                      }
                      
                      return $this->outputArray($options, $count);
                      
                      



                      my current Products-config:

                      {
                        "formtabs":[
                          {
                            "MIGX_id":1,
                            "caption":"Product Info",
                            "print_before_tabs":"0",
                            "fields":[
                              {
                                "MIGX_id":1,
                                "field":"prod_no",
                                "caption":"Product Number",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              },
                              {
                                "MIGX_id":2,
                                "field":"line_id",
                                "caption":"Belongs to Product Line:",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"productlines",
                                "inputTVtype":"",
                                "validation":"required",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              },
                              {
                                "MIGX_id":3,
                                "field":"grp_id",
                                "caption":"Product Group",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"productgroups",
                                "inputTVtype":"",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              },
                              {
                                "MIGX_id":10,
                                "field":"colors",
                                "caption":"Color Group",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"colorgroups",
                                "inputTVtype":"",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              },
                              {
                                "MIGX_id":5,
                                "field":"category",
                                "caption":"Product Category",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"listbox",
                                "validation":"required",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"@EVAL return 'select one==||' . $modx->runSnippet('migxLoopCollection', array('classname'=>'productCategory','tpl'=>'@CODE:[[+name]]==[[+id]]','outputSeparator'=>'||'));",
                                "default":""
                              },
                              {
                                "MIGX_id":4,
                                "field":"options",
                                "caption":"Product Specifications",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"migx",
                                "validation":"",
                                "configs":"Options",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              },
                              {
                                "MIGX_id":7,
                                "field":"qty",
                                "caption":"Quantity",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"number",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              },
                              {
                                "MIGX_id":8,
                                "field":"id",
                                "caption":"",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"none",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              }
                            ]
                          },
                          {
                            "MIGX_id":2,
                            "caption":"Additional Product Settings",
                            "print_before_tabs":"0",
                            "fields":[
                              {
                                "MIGX_id":1,
                                "field":"sample",
                                "caption":"Sample Available?",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"listbox",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"No==0||Yes==1",
                                "default":"0"
                              },
                              {
                                "MIGX_id":2,
                                "field":"sample_qty",
                                "caption":"How many can be ordered?",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":"0"
                              },
                              {
                                "MIGX_id":3,
                                "field":"so",
                                "caption":"Is this a special order item?",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"yes-no-list",
                                "inputTVtype":"",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":"0"
                              },
                              {
                                "MIGX_id":11,
                                "field":"so_text",
                                "caption":"Special Order Text",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"",
                                "default":""
                              },
                              {
                                "MIGX_id":10,
                                "field":"disabled",
                                "caption":"Hide This Product?",
                                "description":"",
                                "description_is_code":"0",
                                "inputTV":"",
                                "inputTVtype":"listbox",
                                "validation":"",
                                "configs":"",
                                "restrictive_condition":"",
                                "display":"",
                                "sourceFrom":"config",
                                "sources":"[]",
                                "inputOptionValues":"No==0||Yes==1",
                                "default":"0"
                              }
                            ]
                          }
                        ],
                        "contextmenus":"update||duplicate||remove",
                        "actionbuttons":"addItem",
                        "columnbuttons":"update||duplicate||remove",
                        "filters":[
                          {
                            "MIGX_id":1,
                            "name":"search",
                            "label":"Product Search",
                            "emptytext":"",
                            "type":"textbox",
                            "getlistwhere":{
                              "prod_no:LIKE":"%[[+search]]%",
                              "OR:options:LIKE":"%[[+search]]%"
                            },
                            "getcomboprocessor":"",
                            "combotextfield":"",
                            "comboidfield":"",
                            "comboparent":"",
                            "default":""
                          }
                        ],
                        "extended":{
                          "migx_add":"Add Product",
                          "formcaption":"Product Manager",
                          "update_win_title":"",
                          "win_id":"ProductList",
                          "maxRecords":"",
                          "addNewItemAt":"bottom",
                          "multiple_formtabs":"",
                          "actionbuttonsperrow":4,
                          "winbuttonslist":"",
                          "extrahandlers":"this.duplicate",
                          "filtersperrow":4,
                          "packageName":"rhythmcatalog",
                          "classname":"productInfo",
                          "task":"products",
                          "getlistsort":"prod_no",
                          "getlistsortdir":"",
                          "use_custom_prefix":"0",
                          "prefix":"",
                          "grid":"",
                          "gridload_mode":2,
                          "check_resid":"0",
                          "check_resid_TV":"",
                          "join_alias":"",
                          "has_jointable":"no",
                          "getlistwhere":"",
                          "joins":[
                            {
                              "alias":"ProductLine"
                            }
                          ],
                          "cmpmaincaption":"",
                          "cmptabcaption":"Product Listing",
                          "cmptabdescription":"This is a listing of all products in the Rhythmlink database",
                          "cmptabcontroller":"",
                          "winbuttons":"",
                          "onsubmitsuccess":"",
                          "submitparams":""
                        },
                        "columns":[
                          {
                            "MIGX_id":1,
                            "header":"id",
                            "dataIndex":"id",
                            "width":"",
                            "sortable":"false",
                            "show_in_grid":"0",
                            "renderer":"",
                            "clickaction":"",
                            "selectorconfig":"",
                            "renderchunktpl":"",
                            "renderoptions":"[]"
                          },
                          {
                            "MIGX_id":3,
                            "header":"Product Number",
                            "dataIndex":"prod_no",
                            "width":"",
                            "sortable":true,
                            "show_in_grid":1,
                            "renderer":"this.renderRowActions",
                            "clickaction":"selectFromGrid",
                            "selectorconfig":"",
                            "renderchunktpl":"",
                            "renderoptions":"[]"
                          }
                        ]
                      }
                      



                      I would hide the products for a new created productline with restrictive condition in the products-field of the productlines - configuration with:

                      [[+id:is=``:then=`1`:else=`0`]]


                      the same for product-groups and other fields, which shouldn't be visible/editable on the productline - create-form.

                      [ed. note: Bruno17 last edited this post 10 years ago.]
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!