Hi everyone,
Am kinda new to drupal but have been fiddling around for a week or so.
Now I am trying to create a module that basically does the same thing as the user module, which is create some data and store it in a database.
Heres how it goes,
-the user presses the 'view data' menu item, which will list all the data in the database, just like in the user menu.
- then there will be a 'add new data' tab in it (like 'add user' in user menu).
-when i press that, i have a form, which will let the user enter the data, and the save button underneat the form will submit the data into the database.
My problem is, when I press the save button, the data never gets saved, and instead, the user is taken to the 'view data' page. :S
Here is some code...
function mine_admin(){//this is called for when the 'view data' is clicked
$edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$op = isset($_POST['op']) ? $_POST['op'] : '';
if (empty($op)) {
$op = arg(2);
}
switch ($op) {
case 'create':
$output = mine_new();
break;
default:
$output = mine_asset_list();
}
return $output;
}
function mine_new(){
$form ['code'] = array (
'#type' => 'textfield',
'#title' => t('code'),
'#required' => TRUE
);
$form ['Name'] = array (
'#type' => 'textfield',
'#title' => t('Name'),
'#required' => TRUE
);