By Gaby on
Hi,
I'm trying to make a module with a specific handling of a file, so I do not want to use upload module, thanks.
I've resumed my problem in a toto module, which is below. I've tried several things, without success. I have always a "toto file field is required.".
<?php
function toto_node_info() {
return array(
'toto' => array('name' => t('toto'), 'base' => 'toto')
);
}
function toto_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'node/add/toto', 'title' => t('toto'),
'access' => user_access('test toto'));
}
return $items;
}
function toto_form(&$node, &$param) {
$form['totofile'] = array(
'#type' => 'file',
'#title' => t('toto file'),
'#required' => TRUE,
'#weight' => 0);
return array_merge($form, filter_form($node->format));
}
function toto_form_alter($form_id, &$form) {
$form['#attributes'] = array('enctype' => 'multipart/form-data');
}
function toto_validate(&$node) {
if ($file = file_check_upload('totofile')) {
}
}
?>
Thank you.
Comments
Ok...
Ok...
I'm a bit disappointed as no doc is available on how files should be managed inside a module. Of course we have file functions, but they are only used inside image and upload modules. And we can't say that those modules are simple...
So please, help me to fix my toto module, as it should not be that hard for a module guru ;)
Cheers
Ok so it looks like nobody
Ok so it looks like nobody care about devs around here, this is a bit shamy as my joomla component would have been a great module for drupal...
Anyway, my question is quite simple :
How to add a mandatory file to a node?
Ok the solution was just
The solution was just there :
http://cvs.drupal.org/viewcvs/drupal/contributions/docs/developer/exampl...