Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Is it possible to make part of textitem read-only?

    Hello, please take a look at the attached screenshot.

    I'm making it possible to add users from several countries. So i have a country-selector, and when it is selected, i fill in the beginning of the phone number, as in the image. It works well, but the user can then manually screw the number up. I'd like to try and prevent that (of course i will do server-side checks, but it will make the user experience client-side better)

    So, is it possible somehow to make the country-prefix in the TextItem greyed out and non-editable? Just checking. I suppose i could have a label to the left too, but it will look much worse, and i like to make things easy on the eyes :)

    Thoughts appreciated!

    Click image for larger version

Name:	Screen Shot 2017-06-11 at 15.39.34.png
Views:	70
Size:	22.3 KB
ID:	245036

    #2
    Hi,

    have you tried the Methode "setCanEdit()"?
    Or you can use a "StaticTextItem" which only display a value.

    Best regards.

    Comment


      #3
      I'd try a keyPressFilter with the e.g. "(+33)" as prefix. Don't know if this will work.
      Or a ChangeHandler, which disallows the delete of the leading "(+33)".
      Or 2 TextItems, one with setCanEdit(false).

      Best regards
      Blama

      Comment


        #4
        Thanks for response guys. Changehandler is hard, since it requires checking copy/paste, control-a-delete etc. I think it will be hard to get a robust solution, unfortunately. I use keypressfilters for dates and such, but i can't see how it would work for this. Ah well.

        Comment


          #5
          I think i would do this with a combination of StaticTextItem for the prefix and the flag as FormItemIcon. Then an extra Field/Form with setShowTitle=false and setTitleSuffix("") for the normal value. (Not exactly what you are looking for, but no better idea ;-) )

          Comment

          Working...
          X