public function deleteField($fieldname) {

        $field = $this->getField($fieldname);
        if ($field) {
            $i = $this->findFieldInArray($fieldname);
            // Look for prev and next field
            $prevfield = $this->getField($field->getPrevious());
            $nextfield = $this->getField($field->getNext());
            // Change their previous and next attributes
            if ($prevfield) {
                $prevfield->setNext($field->getNext());
            }
            if ($nextfield) {
                $nextfield->setPrevious($field->getPrevious());
            }
            // Delete the field
            unset($this->fields[$i]);
            // Reorder the whole structure
            $this->orderFields($this->fields);
            // Recalculate the hash
            $this->calculateHash(true);
            // We have one deleted field, so the table has changed
            $this->setChanged(true);
        }
    }