In my custom entity I want to set a base scheme field, which is an integer. The field has a minimum of 0, a maximum of 360 and a default of 180.
I tried this so:
$fields['pan'] = BaseFieldDefinition::create('integer')
->setLabel(t('PAN'))
->setDescription(t('Horizontal Positioning'))
->setSettings(array(
'default_value' => 180,
'min_value' => 0,
'max_value' => 360
))
->setDisplayOptions('view', array(
'label' => 'inline',
'type' => 'default',
'weight' => -3,
))
->setDisplayOptions('form', array(
'type' => 'number',
'weight' => -3,
'settings' => array(
'default_value' => 180,
'min' => 0,
'max' => 360
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Neither the form is limited nor the input is limited when I post.
How can I get the correct type for my form and the correct settings? How can I look for them? Where?
Edit: solution is the following:
$fields['pan'] = BaseFieldDefinition::create('integer')
->setLabel(t('PAN'))
->setDescription(t('Horizontal Positioning'))
->setDefaultValue(180)
->setSettings(array(
'min' => 0,
'max' => 360
))
->setDisplayOptions('view', array(
'label' => 'inline',
'type' => 'number_integer',
'weight' => -3,
))
->setDisplayOptions('form', array(
'type' => 'number',
'weight' => -3,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);