I am using Drupal 8.4. I am trying to dynamically create/update field data for a content type.
Is there a way to get the type of a field (e.g. text, image, file upload) for a content type?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityYou can obtain the field type using Entity field manager.
$definitions = \Drupal::service('entity_field.manager')
->getFieldStorageDefinitions('node');
$field_type = $definitions['field_image']->getType();
"The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Component\Plugin\Exception\PluginNotFoundException</em>: The "article_text" entity type does not exist. in <em class="placeholder">Drupal\Core\Entity\EntityTypeManager->getDefinition()</em> (line <em class="placeholder">133</em> of <em class="placeholder">core\lib\Drupal\Core\Entity\EntityTypeManager.php</em>)."
– Kiran
Feb 6 '18 at 6:57