ProspectDirector.Web.UI.Packagers.FormFieldValueProvider =
ProspectDirector.Web.UI.Packagers.PackagerValueProvider.extend({

    //================================
    // FIELDS
    //================================

    _regex: /field:(.*)/,

    //================================
    // PUBLIC METHODS
    //================================

    getValue: function (context, command) {

        var result = null,
            field = null,
            fields = new ProspectDirector.Web.List(context.form.get_fields()),
            id = this._processValue(command.get_value());

        fields.each(function (index, item) {
            if (item.get_id() == id) {
                field = item;
                result = item.getValue();
                return false;
            };
        });

        this._checkIsRequired(command, field, result);

        return result;

    },

    canProcessValue: function (value) {
        return value != null
            && ProspectDirector.Web.Type.isString(value)
            && value.match(this._regex) !== null;
    },

    //================================
    // PRIVATE METHODS
    //================================

    _processValue: function (value) {
        var result = value.match(this._regex);
        if (result) {
            result = result[1];
        }
        return result;
    },

    _checkIsRequired: function (command, field, providedValue) {

        var required = command.get_required();

        if (required && providedValue == null) {
            command.get_errors().add(field.options.data.label + " must have a value.");
        }

    }

});