Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We have the ability to create dummy nodes through install_save_node()
. And filling out some basic fields for those nodes is also no problem as long as they can be added to the node object like $node->field_name[0][value]
- but filefields are a little bit trickier. Here's what I've tried out so far - though this is certainly not working yet. Maybe I could get a little help.
Comments
Comment #1
EclipseGc CreditAttribution: EclipseGc commentedTry something like this:
Obviously this will not work for multiple filefields on the same node type, but w/ a little tweaking it could do that too.
Hope this pushes you in a helpful direction.
Eclipse
Comment #2
sirkitree CreditAttribution: sirkitree commentedOk, so this is working pretty well for one image, just have to get it working with two now...
Comment #3
sirkitree CreditAttribution: sirkitree commentedOk, this cleans things up a bit. Makes multiple images work too!
There's one comment in there about doing something better.. namely switching between typecasts... I know there's a better way to do this just can't remember right now...
Comment #4
sirkitree CreditAttribution: sirkitree commentedSorry last patch was corrupt: try this one.
Also of note, there should be a more generalized way to do validation, similar to
_content_field_invoke()