我在节点编辑页面上看到了文本字段和ckeditor字段,但是当我尝试保存节点时,我收到“此值应该是正确的基本类型。”错误。
tsconfig.json
我看到我可以在WidgetBase中使用massageFormValues()方法,但我不知道如何使用它。
欢迎提供一些帮助。
谢谢
答案 0 :(得分:1)
最后我添加到ProgramWidget:
/**
* {@inheritdoc}
*/
public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
foreach ($values as &$value) {
if (count($value['programmation'])) {
$value['programmation'] = $value['programmation']['value'];
} else {
$value['programmation'] = $value['programmation'] !== '' ? $value['programmation'] : '0';
}
}
return $values;
}
}
现在它正在运作
答案 1 :(得分:0)
您正尝试将varchar设置为5000字符大小,但它只允许255 你的错误:
interface IHasObjectName {
objectName: string;
}
class example<A extends IHasObjectName, B extends IHasObjectName> {
constructor(a: A, b: B) {
this[a.objectName] = function() { return a; };
this[b.objectName] = function() { return b; }
}
}
class Cat implements IHasObjectName {
objectName: string = "";
}
class Dog implements IHasObjectName {
objectName: string = "";
}
let cat = new Cat();
cat.objectName = "Cat";
let dog = new Dog();
dog.objectName = "Dog";
let test = new example<Cat,Dog>(cat, dog);
// ??? TYPESCRIPT DOESN'T KNOW ABOUT THESE DYNAMIC PROPERTIES
// HOW DO I MAKE THIS WORK?
let d = test.Dog();
let c = test.Cat();
// I know I could access like this
// let d = test["Dog"]();
// but I want to access like function and have it typed
如果你需要5000个字符使用TEXT类型,你不需要精确的尺寸&#39;属性,它仅适用于整数
答案 2 :(得分:0)
似乎是因为
$element['programmation'] = array(
'#type' => 'text_format',
'#title' => $this->t('Programmation'),
'#placeholder' => $this->getSetting('placeholder_programmation'),
'#default_value' => isset($items[$delta]->programmation) ? $items[$delta]->programmation : NULL,
'#format' => 'full_html',
);
但我不知道如何覆盖方法massageFormValues ..?