Removes a field from a document.

@param string $field field to remove

@return object $this
519001
public function remove($field)
    {
        if (! is_array($field)) {
            $field = func_get_args();
        }

        foreach ($field as $f) {
            $this->update('$unset', $f, 1);
        }

        return $this;
    }
1190863
public function mremove(array $fields)
    {
        $removed = 0;

        foreach ($fields as $field) {
            $removed += $this->remove($field);
        }

        return $removed;
    }
193315
public function removeFieldByName($name)
    {
        foreach ($this->fields as $i => $field) {
            if ($field->getName() == $name) {
                unset($this->fields[$i]);
                break;
            }
        }

        return $this;
    }
664179
public function fieldQuery($field)
    {
        $query = $this->dsql()->del('fields');
        if (is_string($field)) {
            $field = $this->getElement($field);
        }
        $field->updateSelectQuery($query);

        return $query;
    }
2946
public static function cleanField($field) {
        if ('*' == $field) {
            return $field;
        }
        $strings = explode('.', $field);
        $fields  = [];
        foreach ($strings as $str) {
            $strs = preg_split('#\bas\b#i', $str);
            $fs   = [];
            foreach ($strs as $s) {
                if ($s == '*') {
                    $fs [] = '*';
                } else {
                    $fs [] = '`' . trim(trim(trim($s), '`')) . '`';
                }
            }
            $fields [] = implode(' AS ', $fs);
        }

        return implode('.', $fields);
    }
1201110
public function addField(Field $field)
    {
        $field
            ->setSection($this->currentSection)
            ->setOptionName($this->registry['option_name'])
        ;

        if (isset($this->registry['field_values'][$field->getId()])) {
            $field->setValue($this->registry['field_values'][$field->getId()]);
        }

        $this->registry['fields'][] = $field;

        return $this;
    }
1173462
public function deleteElementFromList(
        string $field,
        string $condition
    ): self {
        $this->changes[] = [
            'field' => $field,
            'type' => self::TYPE_ARRAY_ELEMENT_DELETE,
            'condition' => $condition,
        ];

        return $this;
    }
363696
public function removeAdditionalField(string $key): self
    {
        if (isset($this->additionalFields[$key])) {
            unset($this->additionalFields[$key]);
        }

        return $this;
    }
356625
protected function load($field)
    {
        if (!is_null($this->$field)
            || !$this->delegatesCollection
            || !$this->delegatesCollection->containsKey($key = strtolower($field))
        ) {
            return $this->$field;
        }

        $loader = $this->delegatesCollection->get($key);
        $this->delegatesCollection->remove($key);

        return $this->$field = $loader($this);
    }
287187
public function readdField($field)
    {
        $this->checkValidLoader();

        foreach ($this->loaders as $loader => $fields) {
            if (in_array($field, $this->loaders[ $loader ])) {
                array_splice($this->loaders[ $loader ], array_search($field, $this->loaders[ $loader ]), 1);
            }
        }

        $this->addField($field);

        return $this;
    }
189617
protected static function filter($field)
    {
        $field = preg_replace('/[\.\/\\:;,?$*!#_-]/', '', $field);
        $field = preg_replace('/\s+/', ' ', trim($field));
        return $field;
    }
1294387
function delete_field() {
        global $DB;

        if (!empty($this->field->id)) {
            // Get the field before we delete it.
            $field = $DB->get_record('data_fields', array('id' => $this->field->id));

            $this->delete_content();
            $DB->delete_records('data_fields', array('id'=>$this->field->id));

            // Trigger an event for deleting this field.
            $event = \mod_data\event\field_deleted::create(array(
                'objectid' => $this->field->id,
                'context' => $this->context,
                'other' => array(
                    'fieldname' => $this->field->name,
                    'dataid' => $this->data->id
                 )
            ));
            $event->add_record_snapshot('data_fields', $field);
            $event->trigger();
        }

        return true;
    }
133989
public function addField($field)
    {
        $entityFieldNames = array_flip($this->mappedFields);
        if (array_key_exists($field, $entityFieldNames)) {
            parent::addField($entityFieldNames[$field]);
        }

        return $this;
    }
897254
public function withoutHeader(string $field): self {
        $lower = \strtolower($field);

        $clone = clone $this;

        unset(
            $clone->headerCaseMap[$lower],
            $clone->headers[$lower]
        );

        return $clone;
    }
318581
public function pushField(Field $field)
    {
        $field = $this->formatField($field);

        $this->fields->push($field);

        return $this;
    }
966256
public function remove(Document $document)
    {
        $this->pool->attach($document, self::STATE_REMOVE);

        return $this;
    }
553390
public function fields($fields)
    {
        $fields = is_array($fields) && func_num_args() === 1 ? $fields : func_get_args();
        $this->_parts['fields'] = Set::merge($this->_parts['fields'], $fields);
        return $this;
    }