Implements hook_field_widget_third_party_settings_form().

File

./autofill_fields.module, line 12

Code

function autofill_fields_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
    // Skip some fields.
    if (in_array($field_definition->getName(), [
        'authored_by',
        'authored_on',
        'title',
        'path',
        'comment',
    ])) {
        return [];
    }
    $element = [
        'autofill' => [
            '#type' => 'checkbox',
            '#title' => t('Autofill field'),
            '#description' => t('Autofill field for new entities with last used value.'),
            '#default_value' => $plugin->getThirdPartySetting('autofill_fields', 'autofill', FALSE),
        ],
    ];
    return $element;
}