Ejemplo n.º 1
0
 /**
  * Adds Fields for internal use:
  * - One field that specifies the unique id of the form (useful if several
  *   forms are on one page)
  * - One field that specifies the page number of the form (for multi-page
  *   forms)
  * - For multi-page-forms, each page gets all fields of the preceding page
  *   as hidden constant Fields
  */
 private function addInternalFields()
 {
     $i = 0;
     foreach ($this->fieldCollections as $collection) {
         $collection->getDisplay()->setInvisible();
         $pageNumber = new \Feeld\Field\Constant(new \Feeld\DataType\Integer(), self::PREFIX_FIELD_PAGE . $this->getId(), new \Feeld\Display\HTML\Input('hidden'));
         $pageNumber->setDefault($i);
         $collection->addField($pageNumber);
         $collection->addField((new \Feeld\Field\Constant(new \Feeld\DataType\Str(new \Sanitor\Sanitizer(FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH)), $this->getId(), new \Feeld\Display\HTML\Input('hidden')))->setDefault($this->getUniqueID())->addValidator(new \Wellid\Validator\MinLength(13)));
         $lastCollection = $collection;
         if ($i > 0) {
             $collection->addCollection($this->transformToConstants($lastCollection));
         }
         $i++;
         $valueMapper = new ValueMapper(new HTMLFormInternalFields(), ValueMapStrategy::MAP_SETTERS, array(self::PREFIX_FIELD_PAGE . $this->getId() => 'PageNumber', $this->getId() => 'UID'));
         $valueMapper->setId(self::PREFIX_VALUE_MAPPER . $this->getId());
         $collection->addValueMapper($valueMapper);
     }
 }
Ejemplo n.º 2
0
 /**
  * Sets a ValueMapper defaulting to mapping all Fields of this FieldCollection
  * with the same ValueMapStrategy
  * 
  * @param object $object
  * @param int $strategy
  */
 public function addDefaultValueMapper($object, $strategy = ValueMapStrategy::MAP_PUBLIC)
 {
     $mappedProperties = array();
     foreach ($this->getFields() as $field) {
         if ($field instanceof IdentifierInterface && $field->hasId()) {
             $mappedProperties[] = $field->getId();
         }
     }
     $vm = new ValueMapper($object, $strategy, $mappedProperties);
     $vm->setId(FieldCollectionInterface::VALUE_MAPPER_DEFAULT_ID);
     $this->addValueMapper($vm);
 }