protected function validate_competencyframeworkid($value) {

        // During update.
        if ($this->get('id')) {

            // Ensure that we are not trying to move the competency across frameworks.
            if ($this->beforeupdate->get('competencyframeworkid') != $value) {
                return new lang_string('invaliddata', 'error');
            }

        } else {
            // During create.

            // Check that the framework exists.
            if (!competency_framework::record_exists($value)) {
                return new lang_string('invaliddata', 'error');
            }
        }

        return true;
    }