Example #1
0
 /**
  * @return mixed
  */
 public function getValue()
 {
     if ($this->isUnloaded()) {
         return null;
     }
     return parent::getValue();
 }
Example #2
0
 /**
  * Set metadata
  *
  * @param mixed $key   Data key
  * @param mixed $value Data value
  *
  * @return $this
  */
 public function setMetadata($key, $value)
 {
     $data = $this->metadata->getValue();
     $metadata = $this->encoder->decode($data);
     $metadata[$key] = $value;
     $data = $this->encoder->encode($metadata);
     $this->metadata->setValue($data);
     return $this;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function setValue($value)
 {
     if ($value === null) {
         $value = array();
     } elseif (!Value::isArray($value)) {
         throw new InvalidArgumentException(sprintf("Field set value has invalid type: '%s'", gettype($value)));
     }
     return parent::setValue($value);
 }
Example #4
0
 /**
  * Add a field
  *
  * @param Field $field Field
  *
  * @return $this
  * @throws \LogicException
  */
 public function addField(Field $field)
 {
     $name = $field->getName();
     if ($this->hasField($name)) {
         throw new \LogicException(sprintf("Field '%s' already exist.", $name));
     }
     $this->fields[$name] = $field;
     return $this;
 }
Example #5
0
 /**
  * @{@inheritdoc}
  */
 public function __construct(Form $form, $name)
 {
     parent::__construct($form, $name);
     $this->addFilter(new Filter\StripTags($form->getContext()));
 }