/** * @param string $key Input field key * @param string $type Input field type * @param array $options */ public function add($key, $type = self::TYPE_STRING, $options = []) { $node = new self(); $node->setType($type); if (isset($options['required'])) { $node->setRequired($options['required']); } if (isset($options['constraints'])) { $node->setConstraints($options['constraints']); } $this->offsetSet($key, $node); return $node; }