Announcement

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

    Hint style when form item is disabled

    I was wondering if there was a way to change to style of a hint when the form item it's attached to is disabled. Thanks!

    #2
    You can call setHintStyle() with a distinct style.

    Comment


      #3
      That works to change the style but I wanted to have two separate styles for when the form item is enabled and disabled. For example, when the form item is enabled, the hint is blue. When the form is disabled, the hint is green.

      I tried calling setHintStyle("myStyle") and adding a myStyleDisabled style in my css file but that didn't work.

      Comment


        #4
        Right, it doesn't automatically change since it's typically a subdued color anyway. If you want it to change, you'll need to call setHintStyle() at the same time that you call disable().

        Comment


          #5
          Thanks for the hint. We were disabling the items using DynamicForm.setDisabled() so we overrode it to loop through the items and disable the form items manually:
          Code:
          @Override
          public void setDisabled(boolean disabled) {
              super.setDisabled(disabled);
              for (FormItem item : getFields()) {
                  item.setDisabled(disabled);
              }
          }
          In the form items, I overrode the setDisabled method:
          Code:
              @Override
              public void setDisabled(Boolean disabled) {
                  super.setDisabled(disabled);
                  if (disabled) {
                      // Do not call this.setHintStyle
                      super.setHintStyle(hintStyle + "Disabled");
                  } else {
                      super.setHintStyle(hintStyle);
                  }
              }
          
              @Override
              public void setHintStyle(String hintStyle) {
                  // Call super
                  super.setHintStyle(hintStyle);
                  
                  // Save locally
                  this.hintStyle = hintStyle;
              }

          Comment


            #6
            We are also having this issue, it really doesn't feel right to be calling setHintStyle every time we disable, this goes against basic css principles and introduces code which should be in the framework instead of our code :-(.

            Could you please rethink if this is really the best solution.

            Comment


              #7
              At the moment you appear to be only the second person who wants a distinct hint style for disabled items, and it doesn't seem to be a common practice on the web. But we'll watch this thread to see if others want this styling options as well.

              Comment


                #8
                Actually we don't want style for hint fields, we just want our normal styling as applied on regular non-hint fields. I can't see why having a hint would impact styling at all.

                Comment


                  #9
                  Sorry, we don't follow. You've posted in a thread about having a distinct hintStyle for disabled FormItems. If you want something else, please explain in a new thread.

                  Comment


                    #10
                    Sure no problem, sorry for the confusion.

                    Comment

                    Working...
                    X