【发布时间】:2017-07-24 07:25:55
【问题描述】:
我正在使用drupal 8,我有一个实体,我想在实体表单中添加一个隐藏类型字段。如何添加隐藏字段类型?如下所示
<form>
<input type='hidden' name='my_hidden' />
</form>
代码生成形式如下:
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the Timeslot entity.'))
->setReadOnly(TRUE);
return $fields;
}
【问题讨论】: