Create and return a Field Instance.

@param mixed  $type
@param string $name
@param string $value
@param mixed  $inner

@return
972576
private function createField($type, $name, $value, $inner)
    {
        if ($this->hasOptionsMethod($name)) {
            $inner = array_merge($inner, ['options' => $this->getOptions($name)]);
        }

        return $this->fields->create($type, $name, $this->getValue($name), $inner);
    }
1005822
public function addField($name, $type)
    {
        $this->checkNotNull($type, 'type')
            ->checkNotNull($name, 'name')
            ->field_definitions[$name] = $type;

        return $this;
    }
1057771
public static function create($type) {
        switch ($type) {
            case Field::TYPE_CHARACTER:
                return new field\CharacterField;
            case Field::TYPE_DATE:
                return new field\DateField;
            case Field::TYPE_LOGICAL:
                return new field\LogicalField;
            case Field::TYPE_MEMO:
                return new field\MemoField;
            case Field::TYPE_NUMERIC:
                return new field\NumericField;
            default:
                throw new Exception("Unsupported field `$type`");
        }
    }
1236813
protected static function formatFieldValue($name, $value) {
		$field	= static::$validator->getField($name);
		if( $field ) {
			$field->getType()->formatValue($field, $value);
		}
		return parent::formatFieldValue($name, $value);
	}
1349334
public function addField(
        $fieldOrName,
        $classes = [],
        string $type = null,
        $value = null,
        string $title = null
    ) : self {
        if (!$fieldOrName instanceof Field) {
            $fieldOrName = new Field(
                $fieldOrName,
                is_array($classes) ? $classes : [$classes],
                $type,
                $value,
                $title
            );
        }

        $this->fields[] = $fieldOrName;

        return $this;
    }
453013
private function generateIntFieldInput($name, $type, $column)
    {
        $fieldInput = "$name:$type";

        if ($column->getAutoincrement()) {
            $fieldInput .= ',true';
        }

        if ($column->getUnsigned()) {
            $fieldInput .= ',true';
        }

        return $fieldInput;
    }
1136524
public static function createConvertType(
        string $name,
        string $type,
        bool $emptyToNull = false
    ): DenormalizationFieldMappingBuilderInterface {
        $self = new self($name);
        $self->fieldDenormalizer = new ConvertTypeFieldDenormalizer(new PropertyAccessor($name), $type, $emptyToNull);

        return $self;
    }
814424
private function createAttributeValue($name, $value)
    {
        $factory = "create{$name}";

        if ($value instanceof JsonSerializable) {
            $value = $value->jsonSerialize();
        }

        $value = $this->{$factory}($value);

        if (!($value instanceof JsonSerializable || is_array($value))) {
            throw new DomainException('Invalid value factory');
        }

        return $value;
    }
575306
public function input($type = null, $name = null, $value = null)
    {
        $hasValue = $name && (! is_null($this->old($name, $value)) || ! is_null($value));

        return Input::create()
            ->attributeIf($type, 'type', $type)
            ->attributeIf($name, 'name', $this->fieldName($name))
            ->attributeIf($name, 'id', $this->fieldName($name))
            ->attributeIf($hasValue, 'value', $this->old($name, $value));
    }
497796
public static function create($name, $type, array $result)
    {
        list($package, $link, $children) = $result;

        return new self($name, $type, $package, $link, $children);
    }
382817
public static function create(string $name, $value, array $expectedTypes): self
    {
        return new static(sprintf(
            '%s expected to be %s, %s returned',
            ucfirst($name),
            implode(' or ', $expectedTypes),
            is_object($value) ? get_class($value) : gettype($value)
        ));
    }
575134
protected function bindValues($name, $type, $values)
    {
        if (!is_array($values)) {
            return $this->builder->createNamedParameter($values, $type);
        }

        foreach ($values as $key => $value) {
            $values[$key] = $this->bindValues($name, $type, $value);
        }

        return $values;
    }
319214
public function PrimaryKey($Name, $Type = 'int') {
      $Column = $this->_CreateColumn($Name, $Type, FALSE, NULL, 'primary');
      $Column->AutoIncrement = TRUE;
      $this->_Columns[$Name] = $Column;
      
      return $this;
   }
333374
protected function fieldFromRaw($value, $type) {
		switch ($type) {
			case 'int':
			case 'integer':
				return (int)$value;
			case 'float':
				return (float)$value;
			case 'itm':
			case 'item':
				return (int)$value;
			case 'bool':
			case 'boolean':
				return (bool)$value;
			case 'str':
			case 'string':
				return $value;
			case 'binary':
				return bin2hex($value);
			case 'enum':
				return $value;
			case 'dt':
				$obj = NULL;
				if (!empty($value)) {
					$obj = new \Brilliant\BDateTime($value);
				}
				return $obj;
			case 'image':
				if (empty($value)) {
					return NULL;
				}
				$img = new \Brilliant\Images\BImage();
				$img->url = $value;
				return $img;
			case 'json':
				if (empty($value)) {
					return NULL;
				}
				$obj = json_decode($value, true);
				return $obj;
		}
		die('[BItem] fieldFromRaw() Unknown field type "' . $type . '"!');
	}
1221367
public function setFieldValue($name, $value)
    {
        foreach ($this->fields as $key => $fields) {
            if (isset($fields[$name])) {
                $this->fields[$key][$name]->setValue($value);
            }
        }
        return $this;
    }
316677
public function createProperty($name, $type = NULL, $default = self::UNDEFINED, $modifiers = GProperty::MODIFIER_PROTECTED) {
    $gProperty = GProperty::create($name, $type, $default,  $modifiers);
    
    $this->addProperty($gProperty);
    return $gProperty;
  }
1290499
public function createColumn($name, $type = null, array $options = [])
    {
        $this->preventIfLocked();

        if (null !== $type) {
            return $this->getFactory()->createColumnBuilder($name, $type, $options);
        }

        throw new \InvalidArgumentException('Column type guessing is not yet supported.');
        // TODO return $this->getFormFactory()->createBuilderForProperty($this->getDataClass(), $name, $options);
    }