diff --git a/src/Context/ContextDefinition.php b/src/Context/ContextDefinition.php
index 7122d6ec..722eb8d0 100644
--- a/src/Context/ContextDefinition.php
+++ b/src/Context/ContextDefinition.php
@@ -117,4 +117,46 @@ class ContextDefinition extends ContextDefinitionCore implements ContextDefiniti
     return $this;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getWidgetId($dataType) {
+    $widgets = [
+      'text_input' => [
+        'boolean',
+        'datetime',
+        'duration',
+        'email',
+        'entity_reference',
+        'float',
+        'integer',
+        'link',
+        'string',
+        'url',
+      ],
+      'textarea' => [
+        'list',
+        'daterange',
+      ],
+    ];
+
+    foreach ($widgets as $widget_id => $data_types) {
+      foreach ($data_types as $data_type) {
+        if ($dataType == $data_type) {
+          return $widget_id;
+        }
+      }
+    }
+
+    // If we don't recognize the data type, use the "broken" widget.
+    return 'broken';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getWidgetSettings() {
+    return [];
+  }
+
 }
diff --git a/src/Context/ContextDefinitionInterface.php b/src/Context/ContextDefinitionInterface.php
index 118627ca..b65649b1 100644
--- a/src/Context/ContextDefinitionInterface.php
+++ b/src/Context/ContextDefinitionInterface.php
@@ -68,4 +68,24 @@ interface ContextDefinitionInterface extends ContextDefinitionInterfaceCore {
    */
   public function toArray();
 
+  /**
+   * Gets default widget id.
+   *
+   * @param string $dataType
+   *   The data type of the field.
+   *
+   * @return string|null
+   *   A string with the widget id or nothing if the data type needed by
+   *   the context is not supported by any widget.
+   */
+  public function getWidgetId($dataType);
+
+  /**
+   * Gets default configuration of the widget.
+   *
+   * @return array
+   *   An associative array with the default configuration.
+   */
+  public function getWidgetSettings();
+
 }
diff --git a/src/Context/ContextHandlerTrait.php b/src/Context/ContextHandlerTrait.php
index 6e617a41..2bd81bb0 100644
--- a/src/Context/ContextHandlerTrait.php
+++ b/src/Context/ContextHandlerTrait.php
@@ -90,7 +90,7 @@ trait ContextHandlerTrait {
         // If a context mapping has been specified, the value might end up NULL
         // but valid (e.g. a reference on an empty property). In that case
         // isAllowedNull determines whether the context is conform.
-        if (!isset($this->configuration['context_mapping'][$name])) {
+        if (!isset($this->configuration['context_mapping']) || !isset($this->configuration['context_mapping'][$name])) {
           throw new EvaluationException("Required context $name is missing for plugin "
             . $plugin->getPluginId() . '.');
         }
@@ -191,7 +191,7 @@ trait ContextHandlerTrait {
    *   invalid.
    */
   protected function getMappedDefinition($context_name, ExecutionMetadataStateInterface $metadata_state) {
-    if (isset($this->configuration['context_mapping'][$context_name])) {
+    if (isset($this->configuration['context_mapping']) && isset($this->configuration['context_mapping'][$context_name])) {
       return $metadata_state->fetchDefinitionByPropertyPath($this->configuration['context_mapping'][$context_name]);
     }
   }
@@ -269,10 +269,12 @@ trait ContextHandlerTrait {
 
     // Reverse the mapping and apply the changes.
     foreach ($changed_definitions as $context_name => $definition) {
-      $selector = $this->configuration['context_mapping'][$context_name];
-      // @todo: Deal with selectors matching not a context name.
-      if (strpos($selector, '.') === FALSE) {
-        $metadata_state->setDataDefinition($selector, $definition);
+      if (isset($this->configuration['context_mapping'])) {
+        $selector = $this->configuration['context_mapping'][$context_name];
+        // @todo: Deal with selectors matching not a context name.
+        if (strpos($selector, '.') === FALSE) {
+          $metadata_state->setDataDefinition($selector, $definition);
+        }
       }
     }
   }
diff --git a/src/Form/Expression/ContextFormTrait.php b/src/Form/ContextFormTrait.php
similarity index 78%
rename from src/Form/Expression/ContextFormTrait.php
rename to src/Form/ContextFormTrait.php
index e5960d9f..f1f4db07 100644
--- a/src/Form/Expression/ContextFormTrait.php
+++ b/src/Form/ContextFormTrait.php
@@ -1,11 +1,14 @@
 <?php
 
-namespace Drupal\rules\Form\Expression;
+namespace Drupal\rules\Form;
 
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Form\SubformState;
 use Drupal\rules\Context\ContextConfig;
-use Drupal\Core\Plugin\Context\ContextDefinitionInterface;
+// TODO Question: should we do this change?
+use Drupal\rules\Context\ContextDefinitionInterface;
 use Drupal\rules\Context\DataProcessorManagerTrait;
+use Drupal\typed_data\Widget\FormWidgetManagerTrait;
 
 /**
  * Provides form logic for handling contexts when configuring an expression.
@@ -13,6 +16,7 @@ use Drupal\rules\Context\DataProcessorManagerTrait;
 trait ContextFormTrait {
 
   use DataProcessorManagerTrait;
+  use FormWidgetManagerTrait;
 
   /**
    * Provides the form part for a context parameter.
@@ -31,7 +35,7 @@ trait ContextFormTrait {
     // exist default to the "input" mode.
     $mode = $form_state->get('context_' . $context_name);
     if (!$mode) {
-      if (isset($configuration['context_mapping'][$context_name])) {
+      if (isset($configuration['context_mapping']) && isset($configuration['context_mapping'][$context_name])) {
         $mode = 'selector';
       }
       else {
@@ -45,22 +49,44 @@ trait ContextFormTrait {
     if (isset($configuration['context_values'][$context_name])) {
       $default_value = $configuration['context_values'][$context_name];
     }
-    elseif (isset($configuration['context_mapping'][$context_name])) {
+    elseif (isset($configuration['context_mapping']) && isset($configuration['context_mapping'][$context_name])) {
       $default_value = $configuration['context_mapping'][$context_name];
     }
     else {
       $default_value = $context_definition->getDefaultValue();
     }
+
     $form['context'][$context_name]['setting'] = [
-      '#type' => 'textfield',
+      '#type' => 'textarea',
       '#title' => $title,
       '#required' => $context_definition->isRequired(),
       '#default_value' => $default_value,
     ];
 
+    // Use suitable widgets for data entry of values.
+    if ($context_name == 'value') {
+      $dataManager = $context_definition->getTypedDataManager();
+      $dataDefinition = $context_definition->getDataDefinition();
+      $typed_data = $dataManager->create($dataDefinition);
+
+      if (isset($configuration['context_mapping']) && $property_path = $configuration['context_mapping']['data']) {
+        $sub_paths = explode('.', $property_path);
+        $dataType = \Drupal::entityManager()->getStorage('field_storage_config')->load($sub_paths[0] . '.' . $sub_paths[1])->getType();
+
+        if ($widget_id = $context_definition->getWidgetId($dataType)) {
+          $widget = $this->getFormWidgetManager()->createInstance($widget_id);
+          $sub_form = [];
+          $sub_form_state = SubformState::createForSubform($sub_form, $form, $form_state);
+
+          $form['context'][$context_name]['setting'] = $widget->form($typed_data, $sub_form_state);
+        }
+      }
+    }
+
     $element = &$form['context'][$context_name]['setting'];
 
     if ($mode == 'selector') {
+      $element['#type'] = 'textfield';
       $element['#description'] = $this->t("The data selector helps you drill down into the data available to Rules. <em>To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type').</em> More useful tips about data selection is available in <a href=':url'>the online documentation</a>.", [
         ':url' => 'https://www.drupal.org/node/1300042',
       ]);
diff --git a/src/Form/Expression/ActionForm.php b/src/Form/Expression/ActionForm.php
index 96d27bca..02be135e 100644
--- a/src/Form/Expression/ActionForm.php
+++ b/src/Form/Expression/ActionForm.php
@@ -6,6 +6,7 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\rules\Core\RulesActionManagerInterface;
 use Drupal\rules\Engine\ActionExpressionInterface;
+use Drupal\rules\Form\ContextFormTrait;
 use Drupal\rules\Ui\RulesUiHandlerTrait;
 
 /**
@@ -13,9 +14,9 @@ use Drupal\rules\Ui\RulesUiHandlerTrait;
  */
 class ActionForm implements ExpressionFormInterface {
 
-  use ContextFormTrait;
   use StringTranslationTrait;
   use RulesUiHandlerTrait;
+  use ContextFormTrait;
 
   /**
    * The action plugin manager.
diff --git a/src/Form/Expression/ConditionForm.php b/src/Form/Expression/ConditionForm.php
index ee6add0d..9aa2b8ff 100644
--- a/src/Form/Expression/ConditionForm.php
+++ b/src/Form/Expression/ConditionForm.php
@@ -6,6 +6,7 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\rules\Core\ConditionManager;
 use Drupal\rules\Engine\ConditionExpressionInterface;
+use Drupal\rules\Form\ContextFormTrait;
 use Drupal\rules\Ui\RulesUiHandlerTrait;
 
 /**
@@ -13,9 +14,9 @@ use Drupal\rules\Ui\RulesUiHandlerTrait;
  */
 class ConditionForm implements ExpressionFormInterface {
 
-  use ContextFormTrait;
   use StringTranslationTrait;
   use RulesUiHandlerTrait;
+  use ContextFormTrait;
 
   /**
    * The condition plugin manager.
