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 &$form, FormStateInterface $form_state) {
$element['date_text'] = [
'#type' => 'text_format',
'#title' => 'text',
'#format' => 'full_html',
'#default_value' => isset($items[$delta]->date_text) ? $items[$delta]->date_text : NULL,
'#placeholder' => t('Data Text'),
'#element_validate' => array(
array($this, 'validate'),
),
];
$element['date_table'] = [
'#type' => 'textarea',
'#default_value' => isset($items[$delta]->date_table) ? $items[$delta]->date_table : NULL,
'#placeholder' => t('Data Table'),
];
return $element;
}
and this is my schema:
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$schema = [
'columns' => [
'date_text' => [
'type' => 'text',
'size' => 'medium',
],
'date_table' => [
'type' => 'text',
'size' => '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