valueCallback in custom form element is not invoking itself? I am creating a custom form element in my custom module. Everything is working fine except the valueCallback function is not invoking itself. I have done it in following way :

Name space

namespace Drupal\custom_element\Element;


getInfo and valueCallback Method:

public function getInfo() {
    $class = get_class($this);
    return [
      '#input' =&gt; TRUE,
      '#tree' =&gt; TRUE,
      '#process' =&gt; [
        [$class, 'processCheckboxes'],
      ],
      '#theme' =&gt; 'custom_theme',
      '#value_callback' =&gt; ['valueCallback'], // Try with and without #value_callback key
    ];
  }

  /**
   * {@inheritdoc}
   */
  public static function valueCallback(&amp;$element, $input, FormStateInterface $form_state) {
    dsm('in valuecallback');
  }


I am not sure what I am missing.

Related Link : https://www.drupal.org/node/2320115
It doesn't invoke itself when #value is already set to element. I didn't notice that I set it in theme function. After removing #value key from $element array it is working fine.