Newly created fields are not being displayedAuto Fill Content FieldsHow to pre-populate a field with the current users name?newly created fields values are not loaded with node_loadCombine two fields to be displayed togetherWhy is my field not displayed?Form fields created via Ajax are missing element attributesWhy field is double when I print it in node.tpl.phpField group horizontal tabs are displayed as accordions in small screensRelated block by entity reference
How come Aboriginal Australians didn't manage to raise their civilization levels to that of other continents?
Does Turkey make the "structural steel frame" for the F-35 fighter?
Does code obfuscation give any measurable security benefit?
Are Star Trek races uniform?
When and why did the House rules change to permit an inquiry without a vote?
How much does freezing grapes longer sweeten them more?
Conveying the idea of "tricky"
Is it allowed to let the engine of an aircraft idle without a pilot in the plane. (For both helicopters and aeroplanes)
A question about the Tannaka-Krein reconstruction of finite groups
Confused about the meaning of the word "open" in this sentence
Who inspired the character Geordi La Forge?
What's the meaning of Electrical Inches?
What actually is "unallocated space"?
The Immortal Jellyfish
Why doesn't English employ an H in front of the name Ares?
What would a chair for a Human with a Tail look like?
I don't want my ls command in my script to print results on screen
Can elves trance in armor without any downsides?
What are these objects near the Cosmonaut's faces?
Is there a package that allows to write correctly times in hours, minutes and seconds in mathematical mode?
Did I Traumatize My Puppy?
Will I be allowed to enter the US after living there illegally then legally in the past?
Crop Image to Circle
Is there any research on the development of attacks against artificial intelligence systems?
Newly created fields are not being displayed
Auto Fill Content FieldsHow to pre-populate a field with the current users name?newly created fields values are not loaded with node_loadCombine two fields to be displayed togetherWhy is my field not displayed?Form fields created via Ajax are missing element attributesWhy field is double when I print it in node.tpl.phpField group horizontal tabs are displayed as accordions in small screensRelated block by entity reference
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I have a content type "Article" with fields and data that was migrated from a Drupal 7 website.
- In the admin/structure/types/manage/article/fields I added a new text field called "Test" with default value some of some HTML added.
- Then, I went to manage form display and disabled that field from the form
- Then I went to manage display of the appropriate view mode and enabled that field.
- Flushed the cache
Reloading the article page doesn't display the newly added field. I believe it is because there is no value in it, but shouldn't adding a default value to the field pre-populate that field for all previous content belonging to that content type? Or am I missing something here?
8 entities
add a comment
|
I have a content type "Article" with fields and data that was migrated from a Drupal 7 website.
- In the admin/structure/types/manage/article/fields I added a new text field called "Test" with default value some of some HTML added.
- Then, I went to manage form display and disabled that field from the form
- Then I went to manage display of the appropriate view mode and enabled that field.
- Flushed the cache
Reloading the article page doesn't display the newly added field. I believe it is because there is no value in it, but shouldn't adding a default value to the field pre-populate that field for all previous content belonging to that content type? Or am I missing something here?
8 entities
add a comment
|
I have a content type "Article" with fields and data that was migrated from a Drupal 7 website.
- In the admin/structure/types/manage/article/fields I added a new text field called "Test" with default value some of some HTML added.
- Then, I went to manage form display and disabled that field from the form
- Then I went to manage display of the appropriate view mode and enabled that field.
- Flushed the cache
Reloading the article page doesn't display the newly added field. I believe it is because there is no value in it, but shouldn't adding a default value to the field pre-populate that field for all previous content belonging to that content type? Or am I missing something here?
8 entities
I have a content type "Article" with fields and data that was migrated from a Drupal 7 website.
- In the admin/structure/types/manage/article/fields I added a new text field called "Test" with default value some of some HTML added.
- Then, I went to manage form display and disabled that field from the form
- Then I went to manage display of the appropriate view mode and enabled that field.
- Flushed the cache
Reloading the article page doesn't display the newly added field. I believe it is because there is no value in it, but shouldn't adding a default value to the field pre-populate that field for all previous content belonging to that content type? Or am I missing something here?
8 entities
8 entities
edited Jul 9 at 15:27
Jdrupal
3,6814 gold badges10 silver badges34 bronze badges
3,6814 gold badges10 silver badges34 bronze badges
asked May 26 at 6:58
Rana PrathapRana Prathap
1073 silver badges20 bronze badges
1073 silver badges20 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
Adding a default value doesn’t actually set any value in the field. To do that you must either edit the nodes you want the field on and click save, or write an update hook that sets the field value on all the nodes.
An update hook must be placed in a custom module’s .install file, in your case it would be something like:
function MY_MODULE_update_N()
$nodes = Drupal::entityTypeManager()->getStorage('node')->loadByProperties('type' => 'article');
foreach ($nodes as $node)
$node->set('field_name', $value);
$node->save();
As @4k4 mentioned if you have to update too many nodes as you have memory to, you can create batch updates using the &$sandbox, click here for more information
1
If you have more than a few nodes you might run out of memory. Then you need to update in batches via the &$sandbox parameter of the update hook, see the API docs api.drupal.org/api/drupal/…
– 4k4
May 26 at 14:24
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "220"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f281609%2fnewly-created-fields-are-not-being-displayed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Adding a default value doesn’t actually set any value in the field. To do that you must either edit the nodes you want the field on and click save, or write an update hook that sets the field value on all the nodes.
An update hook must be placed in a custom module’s .install file, in your case it would be something like:
function MY_MODULE_update_N()
$nodes = Drupal::entityTypeManager()->getStorage('node')->loadByProperties('type' => 'article');
foreach ($nodes as $node)
$node->set('field_name', $value);
$node->save();
As @4k4 mentioned if you have to update too many nodes as you have memory to, you can create batch updates using the &$sandbox, click here for more information
1
If you have more than a few nodes you might run out of memory. Then you need to update in batches via the &$sandbox parameter of the update hook, see the API docs api.drupal.org/api/drupal/…
– 4k4
May 26 at 14:24
add a comment
|
Adding a default value doesn’t actually set any value in the field. To do that you must either edit the nodes you want the field on and click save, or write an update hook that sets the field value on all the nodes.
An update hook must be placed in a custom module’s .install file, in your case it would be something like:
function MY_MODULE_update_N()
$nodes = Drupal::entityTypeManager()->getStorage('node')->loadByProperties('type' => 'article');
foreach ($nodes as $node)
$node->set('field_name', $value);
$node->save();
As @4k4 mentioned if you have to update too many nodes as you have memory to, you can create batch updates using the &$sandbox, click here for more information
1
If you have more than a few nodes you might run out of memory. Then you need to update in batches via the &$sandbox parameter of the update hook, see the API docs api.drupal.org/api/drupal/…
– 4k4
May 26 at 14:24
add a comment
|
Adding a default value doesn’t actually set any value in the field. To do that you must either edit the nodes you want the field on and click save, or write an update hook that sets the field value on all the nodes.
An update hook must be placed in a custom module’s .install file, in your case it would be something like:
function MY_MODULE_update_N()
$nodes = Drupal::entityTypeManager()->getStorage('node')->loadByProperties('type' => 'article');
foreach ($nodes as $node)
$node->set('field_name', $value);
$node->save();
As @4k4 mentioned if you have to update too many nodes as you have memory to, you can create batch updates using the &$sandbox, click here for more information
Adding a default value doesn’t actually set any value in the field. To do that you must either edit the nodes you want the field on and click save, or write an update hook that sets the field value on all the nodes.
An update hook must be placed in a custom module’s .install file, in your case it would be something like:
function MY_MODULE_update_N()
$nodes = Drupal::entityTypeManager()->getStorage('node')->loadByProperties('type' => 'article');
foreach ($nodes as $node)
$node->set('field_name', $value);
$node->save();
As @4k4 mentioned if you have to update too many nodes as you have memory to, you can create batch updates using the &$sandbox, click here for more information
edited May 26 at 15:57
answered May 26 at 7:05
JdrupalJdrupal
3,6814 gold badges10 silver badges34 bronze badges
3,6814 gold badges10 silver badges34 bronze badges
1
If you have more than a few nodes you might run out of memory. Then you need to update in batches via the &$sandbox parameter of the update hook, see the API docs api.drupal.org/api/drupal/…
– 4k4
May 26 at 14:24
add a comment
|
1
If you have more than a few nodes you might run out of memory. Then you need to update in batches via the &$sandbox parameter of the update hook, see the API docs api.drupal.org/api/drupal/…
– 4k4
May 26 at 14:24
1
1
If you have more than a few nodes you might run out of memory. Then you need to update in batches via the &$sandbox parameter of the update hook, see the API docs api.drupal.org/api/drupal/…
– 4k4
May 26 at 14:24
If you have more than a few nodes you might run out of memory. Then you need to update in batches via the &$sandbox parameter of the update hook, see the API docs api.drupal.org/api/drupal/…
– 4k4
May 26 at 14:24
add a comment
|
Thanks for contributing an answer to Drupal Answers!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f281609%2fnewly-created-fields-are-not-being-displayed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown