I need to attach a field to some bundles. A PHP snippet will do the job for me, so I don't need a module.The below snippet is what must be executed :
$field_name = 'field_custom_image';
// Create the field.
$field = array(
'field_name' => $field_name,
'type' => 'image',
);
field_create_field($field);
and then the snippet to add this field to bundle :
// Create the instance.
$instance = array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'article',
'label' => 'Image',
'description' => 'An image for the article.',
'required' => TRUE,
);
field_create_instance($instance);
Is there a way to run PHP code directly in Drupal, without the need to write a module, install it, make it run, and uninstall it?