public function get($field = null)
    {
        if ($field === null) {

            // Collect list of eligible fields
            $data = [];
            if ($this->only_fields) {
                // collect data for actual fields
                foreach ($this->only_fields as $field) {
                    $data[$field] = $this->get($field);
                }
            } else {
                // get all field-elements
                foreach ($this->elements as $field => $f) {
                    if ($f instanceof Field) {
                        $data[$field] = $this->get($field);
                    }
                }
            }

            return $data;
        }

        $field = $this->normalizeFieldName($field);

        if (array_key_exists($field, $this->data)) {
            return $this->data[$field];
        }

        $f = $this->hasField($field);

        return $f ? $f->default : null;
    }
public function get($field = null)
    {
        if ($field === null) {

            // Collect list of eligible fields
            $data = [];
            if ($this->only_fields) {
                // collect data for actual fields
                foreach ($this->only_fields as $field) {
                    $data[$field] = $this->get($field);
                }
            } else {
                // get all field-elements
                foreach ($this->elements as $field => $f) {
                    if ($f instanceof Field) {
                        $data[$field] = $this->get($field);
                    }
                }
            }

            return $data;
        }

        $field = $this->normalizeFieldName($field);

        if (array_key_exists($field, $this->data)) {
            return $this->data[$field];
        }

        $f = $this->hasField($field);

        return $f ? $f->default : null;
    }
public function get ( $ field = null ) { if ( $ field === null ) { // Collect list of eligible fields $ data = [ ] ; if ( $ this -> only_fields ) { // collect data for actual fields foreach ( $ this -> only_fields as $ field ) { $ data [ $ field ] = $ this -> get ( $ field ) ; } } else { // get all field-elements foreach ( $ this -> elements as $ field => $ f ) { if ( $ f instanceof Field ) { $ data [ $ field ] = $ this -> get ( $ field ) ; } } } return $ data ; } $ field = $ this -> normalizeFieldName ( $ field ) ; if ( array_key_exists ( $ field , $ this -> data ) ) { return $ this -> data [ $ field ] ; } $ f = $ this -> hasField ( $ field ) ; return $ f ? $ f -> default : null ; }
Returns field value.
If no field is passed, then returns array of all field values.

@param mixed $field

@return mixed
Returns field value . If no field is passed then returns array of all field values .