By panoramical1 on
Right, so I have started to make my first module. And after scouring the internet I am stuck. It's to do with the Admin Configuration Page of my module. I have successfully displayed a form, but I am very unsure of how exactly to process the form. I'm new to Drupal, but I know it won't be as simple as just using the standard if(isset($_POST)) etc. etc...I expect there is some "hook" or something similar that I don't understand completely that I need to put in...
My code for the form is as follows:
function randomimage_admin() {
$form['upload'] = array(
'#type' => 'fieldset',
'#title' => t('Remove Images'),
'#tree' => TRUE,
);
$preamble = 'Your current photos are listed below. To remove a photo, ';
$preamble .= 'check its box and press submit.<br/>';
$form ['upload']['preamble'] = array(
'#value' => $preamble,
);
// Now retrieve all the images being used
$result = db_query("SELECT * FROM {randomimage}");
while ($pic = db_fetch_object($result)) {
// Reset the value of the prefix and suffix
$prefix = '';
$suffix = '';
if (!isset($i)) {
$prefix = '<table><tr>';
$i = 0;
}
elseif($i == 0) {
$prefix .= '<tr><td colspan="4"> </td></tr><tr>';
}
$prefix .= '<td class="randomimage" ';
$prefix .= 'style="background-image: url(\'/sites/default/files/images/';
$prefix .= $pic->filename;
$prefix .= '\')">';
$suffix = '</td><td> </td>';
$i++;
if ($i == 4) {
$suffix .= '</tr>';
$i = 0;
}
$form['upload'][$pic->iid] = array(
'#type' => 'checkbox',
'#title' => '',
'#prefix' => $prefix,
'#suffix' => $suffix,
);
}
if ($i != 4) {
$end = '</tr><tr><td> </td></tr>';
}
$end .= '</table>';
$form['upload']['images'] = array(
'#value' => $end,
);
return system_settings_form($form);
}
So what steps do I take to process the form data?
Thanks
Jack
Comments
any help here?
any help here?
check the usage of other
check the usage of other hooks like
hook_insert <--when u add a new node
also :
hook_update <- u will need update node, right?
hook_delete <- of course, u also like to delete the node
and :
hook_submit,
hook_validate
good day ....