Obtain "Label" metadata property of field in renderer

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
  • (Edited)
Is there a way to obtain the specified "label" property for a field from within a field renderer?

field.label and field.metadata.label contain the SFDC label (or the overridden model field value) but not the overridden label text/value from the field editor itself if applicable.

I need to be able to render the label contents in my custom renderer based on what's in the overridden value on the field in the field editor but can't seem to find it available from any property path given the "field" object in the renderer (other field level properties are available).

Possibly I'm just overlooking it.  Is this possible with the current version?

Thank you!
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,206 Points 10k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,530 Points 10k badge 2x thumb
Hi Barry,

field.label is the value that should have this information. This actually works correctly for the table component. I'll put this down as a bug in the field editor component. I think because of this bug, this is not currently possible without parsing the xml of the field editor component yourself. Which would be a total drag.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,228 Points 20k badge 2x thumb
Ha! I see what you did there.   Thanks for all your recent postings Barry.  We are looking into them and will respond.  You just give us such thorny problems that it takes us some time to really understand what's going on... 
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,206 Points 10k badge 2x thumb
Like that one huh?  :)  In all seriousness, the combination of all of these issues has me pretty well stuck on several fronts.  Appreciate you guys (expeditiously) reviewing and addressing.  Thanks Rob!
Photo of JD Bell

JD Bell, Senior Product Engineer

  • 3,006 Points 3k badge 2x thumb
Official Response
This issue is now resolved as of Banzai - Update 7.4, available via Skuid Releases.
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,206 Points 10k badge 2x thumb
Hi JD -

I tested this with Update 7.4 and the field.label no longer contains the model label as it did prior to Update 7.4.  Unfortunately, the string value exposed to the custom renderer on field.label has already gone through merge syntax processing so there still is not a way to obtain the actual field level override in its raw form that was specified in the field editor.

For example, if the label override on the field editor is "Name is {{Name}}", I would expect field.label to contain "Name is {{Name}}" not "Name is JD".  

Is this something that was overlooked?  Expected Behavior?   I would think that merge processing would occur during the rendering of the HTML itself but not the "metadata" that was specified during configuration on field.label.  

On a related note, in order to tackle the issue identified at https://community.skuidify.com/skuid/topics/field-editor-labels-built-using-merge-syntax-do-not-upda..., I would anticipate that leaving field.label in its raw form would be required in order to properly respond to changes in model data.  Instead of using text() during rendering as Skuid does currently when building the label elements, I'm thinking, more than likely, a TemplateComponent will be used to address this issue in which case the raw property value would be needed.

Look forward to your thoughts.  Thanks!
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,530 Points 10k badge 2x thumb
Hi Barry,

I think I agree with you on all these points, and Skuid is not being consistent. Just to clarify, here are the steps I think we should take.

1. Label overrides should be sent to custom renderers raw, and un-merged, no matter whether they originate in the field metadata label override, or in the field component label override.

2. It should be up to the custom renderer author to use the correct skuid apis to populate the merges manually.

3. Skuid should correctly merge label overrides in its standard renderers no matter whether they originate in the field metadata label override, or in the field component label override. (I believe there is currently a bug where field metadata label overrides are not being correctly merged in standard renderers)

Am I understanding this right?
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,206 Points 10k badge 2x thumb
You've pretty much nailed it Ben.  My thoughts are Skuid core/runtime pass in raw (unmerged) and renderer is responsible for renderering.  This would apply to things like helptext, etc., not just labels.

Regarding standard renders, is currently uses "text(....)" to set the value of the div.  My thought is that it should use a TemplateComponent passing it field.label (which would be raw/unmerged given the above) and then you'd solve the issue at https://community.skuidify.com/skuid/topics/field-editor-labels-built-using-merge-syntax-do-not-upda...

By the way, I think the model merge issue you're thinking of is here: https://community.skuidify.com/skuid/topics/merge-syntax-not-processed-when-overriding-label-on-mode...

Thanks!
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,530 Points 10k badge 2x thumb
Great, I've got these issues recorded. I think if we change how things are sent into custom renderers, it would have to be done in a Major update (Skuid 8).
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,206 Points 10k badge 2x thumb
Makes sense, thanks again Ben!
Photo of J.

J., Official Rep

  • 7,714 Points 5k badge 2x thumb
Hi, Barry. I've been working on this for the Rockaway release, and I think I've got it sorted in our dev environment (pending review now). The actual rendering of the label on the screen is still going to be the responsibility of the Component itself (no change there). We'll now send the raw value to the field renderer via the options object, i.e.:
skuid.snippet.register('customFieldRenderer',function(field,value) {
console.log(field.options.label);
});
It looks like we weren't even sending the help text value, so we'll now be sending that in the options object too (field.options.inlineHelpText). As before, field.label will still contain the text of the field's label (i.e. the merged value). This way, anyone who was depending on that merged value won't get caught off guard, but there will now be a way to get the raw value, if you need it.

We're tracking the issue of the labels not updating on model changes separately, but when we have a fix for that one, we'll let you know. Thanks again!
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,206 Points 10k badge 2x thumb
This is great J, thank you!
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,530 Points 10k badge 2x thumb
This fix is now available from skuid.com/releases in the Rockaway Release.
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,206 Points 10k badge 2x thumb
Tested and confirmed with Skuid 8.8.  Thank you!