code/models/EditableField.php
public function onBeforeWrite()
    {
        $return = parent::onBeforeWrite();

        // Field name must be unique
        $exists = self::get()->filter('Name', $this->Name)->exclude('ID', $this->ID);
        if ($exists->count()) {
            throw new ValidationException(
                _t('Moo_EditableField.UNIQUENAME', 'Field name "{name}" must be unique', '',
                    ['name' => $this->Name])
            );
        }

        // Filter field name from un-supported HTML attribute value
        $this->Name = preg_replace('/[^a-zA-Z0-9_]+/', '', $this->Name);

        // Get custom settings from the current object of request POST
        $customSettings = $this->getSettings();
        if (empty($customSettings)) {
            $customSettings = (array) Controller::curr()->getRequest()->postVar('CustomSettings');
        }

        // Filter out any un-supported settings by the subclasss
        if (!empty($this->customSettingsFields)) {
            $customSettings = array_intersect_key($customSettings, array_flip((array) $this->customSettingsFields));
        }

        // Set the filtered settings
        $this->setSettings($customSettings);

        return $return;
    }
public function onBeforeWrite()
    {
        $return = parent::onBeforeWrite();

        // Field name must be unique
        $exists = self::get()->filter('Name', $this->Name)->exclude('ID', $this->ID);
        if ($exists->count()) {
            throw new ValidationException(
                _t('Moo_EditableField.UNIQUENAME', 'Field name "{name}" must be unique', '',
                    ['name' => $this->Name])
            );
        }

        // Filter field name from un-supported HTML attribute value
        $this->Name = preg_replace('/[^a-zA-Z0-9_]+/', '', $this->Name);

        // Get custom settings from the current object of request POST
        $customSettings = $this->getSettings();
        if (empty($customSettings)) {
            $customSettings = (array) Controller::curr()->getRequest()->postVar('CustomSettings');
        }

        // Filter out any un-supported settings by the subclasss
        if (!empty($this->customSettingsFields)) {
            $customSettings = array_intersect_key($customSettings, array_flip((array) $this->customSettingsFields));
        }

        // Set the filtered settings
        $this->setSettings($customSettings);

        return $return;
    }
How to save the data submitted in this field into the database object
which this field represents.

Any class's which call this should also call
{@link parent::populateFromPostData()} to ensure that this method is
called

@throws ValidationException