Primitive Error when saving a custom field with a text_format widget I am trying to make a custom field with one normal textarea and 1 text_format widget.
The textarea functions perfect but if I try to use the text_format widget I get an primitve error when I am trying to save.

This is the error message:


  This value should be of the correct primitive type


This is my formElement:

 public function formElement(FieldItemListInterface $items, $delta, array $element, array &amp;$form, FormStateInterface $form_state) {
  $element['date_text'] = [
  '#type' =&gt; 'text_format',
  '#title' =&gt; 'text',
  '#format' =&gt; 'full_html',
  '#default_value' =&gt; isset($items[$delta]-&gt;date_text) ? $items[$delta]-&gt;date_text : NULL,
  '#placeholder' =&gt; t('Data Text'),
  '#element_validate' =&gt; array(
      array($this, 'validate'),
    ),
];
  $element['date_table'] = [
  '#type' =&gt; 'textarea',
  '#default_value' =&gt; isset($items[$delta]-&gt;date_table) ? $items[$delta]-&gt;date_table : NULL,
  '#placeholder' =&gt; t('Data Table'),
];
return $element;


}

and this is my schema:

  public static function schema(FieldStorageDefinitionInterface $field_definition) {
$schema = [
  'columns' =&gt; [
   'date_text' =&gt; [
      'type' =&gt; 'text',
      'size' =&gt; 'medium',
    ],
    'date_table' =&gt; [
      'type' =&gt; 'text',
      'size' =&gt; 'medium',
    ],
  ],
];

return $schema;


}

It seems, that text_format returns an array instead of a single value and thus cant be saved in my text column. 
The array consists of the text and the format, i dont need the format, so I would need to replace the array with the text value.

How and where could I accomplish this?

Xdebug is not working on scripts that are executed when I click save, so I really have no clue what is really going on.

thanks
Here is what solved the issue:

I used messageFormValues in my Widget.php to override the Array with the text value, so it could be stored in my database.

public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
  foreach($values as $key =&gt; $value) {
    $values[$key][date_text] = $value[date_text][value];
  }
  return $values;
}


To unescape the html for my twig template(so it is displayed as html and not as text on the site) I used the raw attribute.

With this solution no Text-Format will be saved, but it was not necessary for my custom field anyway.