Esempio n. 1
0
 /**
  * Create a FieldCollection based on the current module and fill the field values with $data entries
  *
  * @param array $data
  *
  * @return FieldCollection
  */
 protected function prepareFieldCollection(array $data = array())
 {
     $fieldCollection = new FieldCollection();
     foreach ($this->module->fields as $mField) {
         $field = FieldFactory::make($mField);
         $field->setValue($data[$mField->column_name] ?: null);
         $fieldCollection->add($field);
     }
     return $fieldCollection;
 }
Esempio n. 2
0
 /**
  * Creates a FieldCollection based the current Module instance
  *
  * @return FieldCollection
  */
 public function getFieldCollection()
 {
     if ($this->fieldCollection instanceof FieldCollection) {
         return $this->fieldCollection;
     }
     $collection = new FieldCollection();
     foreach ($this->fields as $field) {
         $className = studly_case($field->type);
         $fullClass = sprintf('Orangehill\\Photon\\Library\\Form\\Fields\\%s\\%s', $className, $className);
         $rField = new $fullClass($field);
         $collection->add($rField, $field->column_name);
     }
     $this->fieldCollection = $collection;
     return $collection;
 }