Skip to main content
deleted 15 characters in body
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

I have the following code to get the value that is stored in a field

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $delta) {      
  dpm($delta->value);
}

With this I can get the correct value let says:

 * id_string1
 * id_string2
 * id_string3

But my field havehas a Field Formatter named title_formatter that will take the string id_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don't know how to apply the Field Formatter programmatically to the field values.?

I have the following code to get the value that is stored in a field

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $delta) {      
  dpm($delta->value);
}

With this I can get the correct value let says:

 * id_string1
 * id_string2
 * id_string3

But my field have a Field Formatter named title_formatter that will take the string id_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don't know how to apply the Field Formatter programmatically to the field values.

I have the following code to get the value that is stored in a field

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $delta) {      
  dpm($delta->value);
}

With this I can get the correct value let says:

 * id_string1
 * id_string2
 * id_string3

But my field has a Field Formatter named title_formatter that will take the string id_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But how to apply the Field Formatter programmatically to the field values?

added 31 characters in body
Source Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

I have the following code to get the value that is stored in a field

$nid = 76;
$node = Drupal\node\Entity\Node\Drupal::loadservice('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $delta) {      
  dpm($delta->value);
}

With this I can get the correct value let says:

 * id_string1
 * id_string2
 * id_string3

But my field have a Field Formatter named title_formatter that will take the string id_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don't know how to apply the Field Formatter programmatically to the field values.

I have the following code to get the value that is stored in a field

$nid = 76;
$node = Drupal\node\Entity\Node::load($nid);
foreach ($node->field_aaaa as $delta) {      
  dpm($delta->value);
}

With this I can get the correct value let says:

 * id_string1
 * id_string2
 * id_string3

But my field have a Field Formatter named title_formatter that will take the string id_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don't know how to apply the Field Formatter programmatically to the field values.

I have the following code to get the value that is stored in a field

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $delta) {      
  dpm($delta->value);
}

With this I can get the correct value let says:

 * id_string1
 * id_string2
 * id_string3

But my field have a Field Formatter named title_formatter that will take the string id_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don't know how to apply the Field Formatter programmatically to the field values.

added 81 characters in body
Source Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

I have the following code to get the value that is stored in a field

$nid = 76;
$node_details$node = Drupal\node\Entity\Node::load($nid);
$id =foreach $field($node->value;>field_aaaa as $delta) {      
  dpm($id$delta->value);
}

With this I can get the correct value let says:

  • id_string
 * id_string1
 * id_string2
 * id_string3

But my field have a Field Formatter named title_formatter that will take the string id_stringid_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don`tdon't know how to apply the Field Formatter programmatically to the field valuevalues.

I have the following code to get the value that is stored in a field

$nid = 76;
$node_details = Drupal\node\Entity\Node::load($nid);
$id = $field->value;  
dpm($id);

With this I can get the correct value let says:

  • id_string

But my field have a Field Formatter named title_formatter that will take the string id_string and will show something like this:

String

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don`t know how to apply the Field Formatter programmatically to the field value.

I have the following code to get the value that is stored in a field

$nid = 76;
$node = Drupal\node\Entity\Node::load($nid);
foreach ($node->field_aaaa as $delta) {      
  dpm($delta->value);
}

With this I can get the correct value let says:

 * id_string1
 * id_string2
 * id_string3

But my field have a Field Formatter named title_formatter that will take the string id_string1 and will show something like this:

String 1

In the UI this works fine if I chose my Title Formatter (title_formatter) for the field I can see the 'String' when I viewing my node.

But I don't know how to apply the Field Formatter programmatically to the field values.

Source Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133
Loading