Skip to content

Instantly share code, notes, and snippets.

@patrickmaciel
Created April 10, 2025 14:01
Show Gist options
  • Save patrickmaciel/92eefc53c0e32245f24b740d1c63b91a to your computer and use it in GitHub Desktop.
Save patrickmaciel/92eefc53c0e32245f24b740d1c63b91a to your computer and use it in GitHub Desktop.
Iterar os campos de um formulario form_state do drupal
<?php
$node = $form_state->getFormObject()->getEntity();
$all_fields = [];
foreach ($node->getFields() as $field_name => $field_item_list) {
$all_fields[$field_name] = $field_item_list->getValue();
}
// Use $all_fields conforme necessário
echo '<pre>';
print_r($all_fields);
echo '</pre>';
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment