While editing a form, I needed to delete some fields and add a new paragraph. The issue here is, the newly added paragraph is not initialized in the edit form and that makes sense because the old data don't have that field so I have to initialize it manually by clicking on "Add Paragraph", then Save otherwise I won't be able to access it programmatically, but I have hundreds of users and I can't do that.

How can I add a paragraph to existing records?

I'm unable to use Drush on this server.

1 Answer 1


You add newly created paragraphs (without saving them) to the node field:

$node->field_paragraph[] = Paragraph::create([
  'type' => 'paragraph_type',
  'field_foo' => 'bar',

and save them later together with the node:

  • I think the question is regarding how to do so in bulk and without Drush. So I think we need also to add at a minimum an entity query and an update hook.
    – mona lisa
    Commented Oct 17, 2022 at 12:40
  • Yes ! it's working fine ! You saved me a lot of hours. Thank you Commented Oct 17, 2022 at 13:49
  • @cilefen I think you are right! How to do that? Commented Oct 17, 2022 at 15:00
  • 1
    I am certain there are answers on this forum for that and all over the Internet. Example: thirdandgrove.com/insights/…. If there are very many of these you may have to enqueue them, but that's only if the update is too time-consuming.
    – mona lisa
    Commented Oct 17, 2022 at 15:12
  • The link you provided was exactly what I needed. Thanks a lot. Commented Oct 18, 2022 at 14:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.