Example #1
0
 /**
  * @param      $formId
  * @param bool $asTokens
  *
  * @return array
  */
 protected function getFormFields($formId, $asTokens = true)
 {
     $fields = $this->fieldModel->getSessionFields($formId);
     $viewOnly = $this->formModel->getCustomComponents()['viewOnlyFields'];
     $choices = [];
     foreach ($fields as $f) {
         if (in_array($f['type'], $viewOnly)) {
             continue;
         }
         $choices[$asTokens ? '{formfield=' . $f['alias'] . '}' : $f['alias']] = $f['label'];
     }
     return $choices;
 }
Example #2
0
 /**
  * @param Form $entity
  * @param      $sessionFields
  */
 public function deleteFields(Form $entity, $sessionFields)
 {
     if (empty($sessionFields)) {
         return;
     }
     $existingFields = $entity->getFields()->toArray();
     $deleteFields = [];
     foreach ($sessionFields as $fieldId) {
         if (isset($existingFields[$fieldId])) {
             $entity->removeField($fieldId, $existingFields[$fieldId]);
             $deleteFields[] = $fieldId;
         }
     }
     // Delete fields from db
     if (count($deleteFields)) {
         $this->formFieldModel->deleteEntities($deleteFields);
     }
 }