New Community Forums are coming. Watch this space for news.
Subscribe: RSS
  • Doesn't seem to work for me.
    It is like it don't know the difference between 0 and a value higher then zero.
    Would still appreciate it a lot if someone has a solution for me!
    • Quote from: marielvdoever at Sep 20, 2018, 10:43 PM
      Doesn't seem to work for me.
      It is like it don't know the difference between 0 and a value higher then zero.
      Would still appreciate it a lot if someone has a solution for me!

      I really wish I knew. I think the goal is to default in the form to a null response, no 0 but just nothing. Then it should be gone...

      in this case maybe each element does have data because its got name of the item

      I am really stumped
      • My advice is still that you need to use a hook rather than relying on chained output modifiers.
          ■ email: lk@alienbuild.uk | ■ website: https://alienbuild.uk

          The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • Ok apologies to LK for going against that idea, I must remember always to listen to LK, which has been proven many times.

          Here is the code he provided before. Its a custom hook that will go in the call along with the email tpl

          The problem is that the field names are dynamic so this is why I advised to setup the names with 'product_', so in a hook you can find any values with this prefix, explode them and then dictate their return - someone may be able to advise you on the correct php for this as I assume mine didnt work wink

          Try this - it may not work but if it fails check the error log for guidance or keep tweaking it to get it work smiley I think each time it loops through the value may be replaced though so I think you need to use str replace... hopefully someone can guide you on that.

          <?php
            
          $allValues = $hook->getValues();
          $product = array();
           
          foreach($allValues as $key => $value) {
              if (strpos($key, 'products_') !== false) {
            
                  $modx->log(xPDO::LOG_LEVEL_ERROR, 'There were values found with the prefix product_');
            
                  list($prefix, $productTitle) = explode('_', $key);
            
                  $modx->log(xPDO::LOG_LEVEL_ERROR,'The products found were:' . $productTitle);
            
                  $productList .= 'Title:' . $product[$key] . 'Quantity' . $product[$value];
            
                  $hook->setValue('products', $productList);
            
                  return true;
            
              } else{
            
                  $modx->log(xPDO::LOG_LEVEL_ERROR, 'There were no values matching product_');
            
                  return false;
            
              }
          }
          • marielvdoever Reply #35, 4 months ago
            Totally forgot to react. But I'd already tried that code, with no luck. And I don't understand anything about hooks. So someone should give me visual codes that work, or explain. It is still not working the way I would want to see it.