Beispiel #1
0
 public function update($ogID)
 {
     $json = Loader::helper('json');
     $ogJSON = $json->decode(file_get_contents("php://input"));
     $og = \Concrete\Package\Formify\Src\FormifyOptionGroup::get($ogID);
     foreach ($ogJSON as $property => $value) {
         $og->set($property, $value);
     }
     $og->setOptions($ogJSON->optionsValues);
 }
Beispiel #2
0
 public function getOptions()
 {
     if ($this->options) {
         return $this->options;
     } else {
         $db = Loader::db();
         $options = array();
         switch ($this->optionsSource) {
             case 'static':
                 // Specify manually
                 $options = $db->getAll("SELECT value as value, value as label FROM " . TABLE_FORMIFY_OPTIONS . " WHERE ffID = ? ORDER BY oID ASC", array($this->ffID));
                 break;
             case 'optionGroup':
                 // Option group
                 $og = \Concrete\Package\Formify\Src\FormifyOptionGroup::get($this->ogID);
                 $options = $og->options;
                 break;
             case 'formRecords':
                 // Form records
                 $rs = \Concrete\Package\Formify\RecordSet::get($this->ogFormID);
                 $rs->setPageSize(0);
                 $records = $rs->getRecords();
                 foreach ($records as $r) {
                     $options[] = array('label' => $r->getAnswer($this->ogFieldID), 'value' => $r->getAnswer($this->ogFieldID));
                 }
                 break;
         }
         $this->options = $options;
         return $options;
     }
 }