5

In Visualforce, we didn't thought much about picklist-values (=options) on simple CRUD UIs - they where simply there using an <apex:inputField ... />

Now in Lightning I found this documentation showing different verbose ways to populate the options either by Markup or JavaScript, but both none driven by metadata - https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ui_select.htm

I like neither of those approaches. Is there any method to get this done better?

The goal is, to populate the values as defined in the setup

  • Record-Type aware
  • Translation aware
  • Dependency aware

A similar (but more specific) question has been asked here Picklist Values in Dynamic Lightning Components

I think in addition to record-type specific values, there are many reasons to make this dynamic, e. g. translations. It is not simple to populate a picklist with exactly the same values as user will see in the standard-UI. Assuming an complex org is already well-configured, it might be a huge piece of work to populate the picklists (reading the schema, evaluating the record-types, translations, etc). This should be done - as in Visualforce - by the platform, but how does it work?

To hardcode picklist-values is the worst option, because you will end up in maintaining them redundatly multiple times, loose configurability by admins and significantly higher implementation efforts.

  • Following this question since I think this is something that hasn't been addressed in Lightning. – akarnid Oct 21 '15 at 9:50
  • @akarnid This would be a massive missing piece if there is no viable workaround. What needs to be done is pretty clear (query schema, transaltions, record-types with apex and deliver the values to the controller.js), but if it's already on the roadmap at Salesforce, it would waste a lot of dev-time to implement it on our own. Maybe I have to implement it anyway, if I can't wait, but it's no fun... – Uwe Heim Oct 21 '15 at 11:07
5

There is something...

I found this post Lightning - How to use force:inputField? and I'm validating this markup

<force:inputField value="{!v.YourAttributeNameForTheSObject.YourFieldname}" />

It's in the documentation

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_force_inputField.htm

The description is very puristic (no further explanation, no example) and this is currently the only match in the documentation I found. It leaves many questions open.

And it works partly. As @Andrew discoverd, picklists come up disabled. Using jQuery to wipe the disabled="" makes them editable and I was surprisingly be able to change a picklist-value and get it saved.

So what does this tell us?

  • Is this officially available or not?
  • What is it capable of and what not?
  • Should we use it or not?
  • Will there be an improvement of documentation and functionality soon?

Please let us know, so that we can plan ahead. This is nothing small. This is very very big - at least in my opinion, since to use ui:inputXXXX is very poor compared to force:inputField

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.