We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34109
    • 119 Posts
    That's working perfectly, just one more thing - I really owe you several beers by now!

    The database column these are populating is in datetime format - would you use custom getlist and update scripts to split these out into the four parts or is there a simpler way to handle it?
      Studio Republic
      http://www.studiorepublic.com
      0845 226 3205
      @christodhunter
      • 4172
      • 5,888 Posts
      I don't think you will need a custom getlist.php

      but a custom fields.php with additions with something like that:

      $record = $object->toArray();
      
      $date = strtotime($record['date']);
      
      $record['year'] = strftime('%Y',$date);
      $record['month'] = (int) strftime('%m',$date);
      $record['day'] = (int) strftime('%d',$date);
      


      you can also create a custom update.php, where you can do some validation, for example, if the timeslot is still availiable, before saving

      or you could create a php-config-file with the same name as your MIGX-config
      example:

      reservation.config.inc.php with something like that:

      <?php
      
      $action = $modx->getOption('action', $_REQUEST, '');
      
      switch ($action) {
          case 'mgr/migxdb/update':
              $data = $modx->getOption('data', $_REQUEST, '');
              $postvalues = $modx->fromJson($data);
      
              $year = $modx->getOption('year', $postvalues, 0);
              $month = $modx->getOption('month', $postvalues, 0);
              $day = $modx->getOption('day', $postvalues, 0);
              $date = $modx->getOption('date', $postvalues, 0);
              $time = $modx->getOption('time', $postvalues, 0);
      
              if (empty($date) && !empty($year) && !empty($month) && !empty($day)) {
                  $postvalues['date'] = $year . '-' . $month . '-' . $day . ' ' .$time;
                  $_REQUEST['data'] = $modx->toJson($postvalues);
              }
      
      
              break;
      }
      
      









        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!