How to render a weight element? I'm trying to render a weight element but it doesn't works I just have as output an empty string. But when I try to render a checkbox I get the correct output.

For the weight element:

$weight = array(
  '#type' =&gt; 'weight', 
  '#title' =&gt; t('Weight'), 
  '#default_value' =&gt; 1, 
  '#delta' =&gt; 10, 
);

// For Drupal 7.    
dpm(drupal_render($weight));
// For Drupal 8.
kint(\Drupal::service('renderer')-&gt;render($weight));


Output: An empty string.

For the checkbox element.

$check = array(
  '#type' =&gt; 'checkbox',
  '#title' =&gt; t('Dry run'),
  '#description' =&gt; t('Test run without deleting revisions but seeing the output results.'),
);
// For Drupal 7.
dpm(drupal_render($check));
// For Drupal 8.
kint(\Drupal::service('renderer')-&gt;render($check));


Output: 

&lt;div class="form-item form-type-checkbox"&gt;
 &lt;input type="checkbox" value="1" class="form-checkbox" /&gt;  &lt;label class="option"&gt;Dry run &lt;/label&gt;

&lt;div class="description"&gt;Test run without deleting revisions but seeing the output results.&lt;/div&gt;
&lt;/div&gt;


So, I think that the drupal_render() function and renderer service are working fine because the checkbox is rendered, but the weight element not, I'm missing something here?
The select element is built in Weight::processWeight():

  /**
   * Expands a weight element into a select element.
   */
  public static function processWeight(&amp;$element, FormStateInterface $form_state, &amp;$complete_form) {
    $element['#is_weight'] = TRUE;

    $element_info_manager = \Drupal::service('element_info');
    // If the number of options is small enough, use a select field.
    $max_elements = \Drupal::config('system.site')-&gt;get('weight_select_max');
    if ($element['#delta'] &lt;= $max_elements) {
      $element['#type'] = 'select';
      $weights = [];
      for ($n = (-1 * $element['#delta']); $n &lt;= $element['#delta']; $n++) {
        $weights[$n] = $n;
      }
      $element['#options'] = $weights;
      $element += $element_info_manager-&gt;getInfo('select');
    }
    // Otherwise, use a text field.
    else {
      $element['#type'] = 'number';
      // Use a field big enough to fit most weights.
      $element['#size'] = 10;
      $element += $element_info_manager-&gt;getInfo('number');
    }

    return $element;
  }


Which is only called in form building, not in normal rendering.