Access the field class from within FieldItemList (D8) When I would like to get the values inserted in a form, I use:

$form_state-&gt;getValue('myfield');


If I would like to have some information on the field definition, I use:

$form_state-&gt;getFormObject()-&gt;getEntity()-&gt;myfield-&gt;getfieldDefinition();


Every time I check the class resulting from the following statement:

$form_state-&gt;getFormObject()-&gt;getEntity()-&gt;myfield


It is of the type Drupal\\Core\\Field\\FieldItemList which is fine for getting/setting the values

Suppose that "myfield" is of the type "language_field" defined in \Drupal\languagefield\Plugin\Field\FieldType\LanguageItem.

This class have a public function 

public function getNativeName()


To get the full name of the language.

But My question is: how to access this function fromwithin the FieldItemList object? (Same problem arise with many other field type)

Added info:

With the help of @Eyal, I could access my object method:

$form_state-&gt;getFormObject()-&gt;getEntity()-&gt;myfield-&gt;get($delta)-&gt;getNativeName()‌​;


But this is valid only if the entity is already saved. 

In the case of a new (or edited) item, the entity doesn't store the new value. Here is the code for what I am trying to explain:

The 2 variables will have the same value if I open and save the form without change, but this will not be the case if I update the item at delta=1.

function my_validate($form, FormStateInterface $form_state) {
  $val_by_entity=$form_state-&gt;getFormObject()-&gt;getEntity()-&gt;myfield-&gt;get(1)-&gt;value;
  $val_by_form_state_value=$form_state-&gt;getValue(['myfield', 1, 'value']);
}
You first need to understand that the entity object in question does not have a property called myfield.

Drupal uses something called magic properties to mask the get method required for retrieving the field item list. See FieldableEntityInterface::get() for more information.

The second thing you should know, is that drupal treats all fields as multi value. That means that a field that is defined to have a single value would still be represented a list with a single item.

Finally, to answer your question, you can either use the FieldItemListInterface::get() method to get the field item object, it you can access it as though it was an array.

$entity-&gt;get('myfield')-&gt;get(0);

OR

$entity-&gt;myfield[0];