Ticket #2528926 (closed enhancement)

Reporter


David Robert
Opened: 05/26/10
Last modified: 09/7/10
Status: closed
Type: enhancement
Resolution: fixed

Owner


Satyen Desai
Target Release: 3.2.0
Priority: P3 (normal)
Summary: Provide access to normalized values for Y.Attribute
Description:

Their may be a number of applications where it would be useful to access the nomalized values of Y.Attribute. The way I would like to use it is for form validation and data formatting.
- the getter/setter functionality is great for formatting: Consider a date or currency string formatted in the locale of the user vs. the date or number normalized value stored internally.
- the validator functionality can be used for checking data types and ranges
- the event functionality is useful for other widgets/forms in the page to react to data changes.

However in practice this does not work because there is no access to normalized values. I would like to see access
- on the Y.Attribute object itself to get/set normalized values for interaction with the server through JSON
- on events so that other forms/widgets can choose to deal with the formatted value or the normalized one.

Perhaps an augmentation to Y.Attribute so that users that want to retain the encapulation of Y.Attribute can do so, but those that want access can get it?

Type: enhancement Observed in Version: 3.1.1
Component: Attribute Severity: S3 (normal)
Assigned To: Satyen Desai Target Release: 3.2.0
Location: Priority: P3 (normal)
Tags: attribute, form, json, ajax Relates To:
Browsers: All
URL:
Test Information:

Change History

Satyen Desai

YUI Developer

Posted: 05/26/10
  • priority changed to P3 (normal)
  • severity changed from S2 (high) to S3 (normal)
  • status changed from new to accepted

I was thinking just a "protected" _getRawValue method (or something similar), which wraps the _state.data.values workaround I gave you. Changed severity to P3 since it has the workaround I mentioned in the forum thread.

David Robert

Posted: 05/26/10

OK, would that also be available in the event object also? That's why I had it as a S2 :)

Satyen Desai

YUI Developer

Posted: 05/26/10

You could call it from the event listener right? What event is it listening for?

If it's something fired by the Attribute augmented object, then you have access to this._state.data.value. If it's something else, then you'd need to maintain a reference to the Attribute augmented object in scope.

David Robert

Posted: 05/26/10

Ug. I forgot the context for the listener was the Y.Attribute object. Sorry, new to JS.

Satyen Desai

YUI Developer

Posted: 05/26/10

np. thanks for the confirmation.

Satyen Desai

YUI Developer

Posted: 07/27/10
  • status changed from accepted to checkedin

I added a _getAttrCfg for 3.2.0pr1, since we needed a way to get at the config for an attribute in general. The object returned will also have the raw value. Let me know if this works for you.

/**
* Returns an object with the configuration properties (and value)
* for the given attrubute. If attrName is not provided, returns the
* configuration properties for all attributes.
*
* @method _getAttrCfg
* @protected
* @param {String} name Optional. The attribute name. If not provided, the method will return the configuration for all attributes.
* @return {Object} The configuration properties for the given attribute, or all attributes.
*/
_getAttrCfg : function(name) {

George

YUI Developer

Posted: 09/7/10
  • milestone changed to 3.2.0

George

YUI Developer

Posted: 09/7/10
  • resolution changed to fixed

George

YUI Developer

Posted: 09/7/10
  • status changed from checkedin to closed