Hi there,
I am new to Drupal and trying to create a database with a dynamic number of fields depending on one of the field inputs. So, I have an input called "num" and then I want to ask for names for a "num" number of times. Here is what I wrote but it is not working. Any ideas?
/**
* Implementation of hook_schema()
*/
function add_family_schema() {
$schema['add_fam'] = array(
'description' => t('Stores the family information.'),
'fields' => array(
'num' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => t('The number of children of the user logging in.'),
)));
foreach ($schema[add_fam][num] as $i) {
$schema['add_fam'] = array(
'fields' => array(
'child_.$i' => array(
'type' => 'char',
'not null' => TRUE,
'description' => t(Child Name'),
));
);
}
$schema['add_fam'] = array(
'index' => array('uid'),
);
return $schema;
}