Skip to main content
martinl90743871
Known Participant
September 12, 2017
Answered

Modale validation

  • September 12, 2017
  • 5 replies
  • 620 views

Hi All,

Is there a way to have a custom function when a user click on the ok button of a modal?
I'd like to validate that an edit-field is filled before exiting the modal and if the validation is not correct, show a new message in red inside the modal to show where is the problem (as the form on Internet)

Currently, I have an option by saving the elements and show a new modal if the validation doesn't pass, but I would prefer to do it by binding or something similar...


Thank you
Martin

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer johnrellis

You can enable or disable the action button of the dialog by setting the "actionBinding" parameter to a property binding:

    local result = LrDialogs.presentModalDialog {title = "My Dialog",

        contents = controls,

        actionBinding = {enabled = {bind_to_object = prop,

            key = "actionEnabled"}}}

You can use more complicated bindings created by LrBinding, e.g. to call a function that evaluates a more complicated condition.

5 replies

johnrellis
johnrellisCorrect answer
Legend
September 12, 2017

You can enable or disable the action button of the dialog by setting the "actionBinding" parameter to a property binding:

    local result = LrDialogs.presentModalDialog {title = "My Dialog",

        contents = controls,

        actionBinding = {enabled = {bind_to_object = prop,

            key = "actionEnabled"}}}

You can use more complicated bindings created by LrBinding, e.g. to call a function that evaluates a more complicated condition.

martinl90743871
Known Participant
September 13, 2017

Sounds a good solution to me :-) Thank

A bit less interactive than what I'd like to do but it's still good.

Thank you John.