Hi,
Again, I'm not far from getting mad :(. I'm developing a module for witch I'm developing a adminpanel. The module I'm creating will enable users to use swf's to replace fonts in their HTML. Something like Sifr, but easier to use.
In the adminpanel I've added an option to manage uploaded fonts. Combined with lots of frustration, I've managed to create a table with the uploaded fonts and checkboxes, witch should enable the administrator to delete fonts. (Thanks to http://drupal.org/node/112358).
Now the next step would be validating the form. This is where I'm stuck. All form elements are accessible, but from the checkboxes I can't get the values (whether they are checked, or not). I must be overlooking something but I can't find it! Please help!
The form:
function flash_text_fonts_form() {
$font_list_table_rows = array();
$font_folder = variable_get("flash_text_font_folder", "files/flash_text");
if($handle = opendir($font_folder)) {
while (false !== ($file = readdir($handle))) {
if(preg_match("/^(.+?).swf$/", $file, $matches)) {
array_push($font_list_table_rows, array("title" => $matches[1], "file" => $matches[0]));
}
}
}
$form['header'] = array('#type' => 'value', '#value' => array(array('data' => 'nid'), array('data' => t('Title'))));
foreach ($font_list_table_rows as $k => $v) {
$check_del_font[$v['file']] = '';
$form['title'][$v['file']] = array('#type' => 'markup', '#value' => $v["title"]);
}
$form['check_del_font'] = array('#type' => 'checkboxes', '#options' => $check_del_font);
$form['submit'] = array('#type' => 'submit', "#value" => t('Save settings'));
return $form;
}
The theme hook to place the form elements in a table
function theme_flash_text_fonts_form($form) {
foreach (element_children($form['title']) as $key) {
$row = array();
$row['data'][0] = drupal_render($form['check_del_font'][$key]);
$row['data'][1] = drupal_render($form['title'][$key]);
$rows[] = $row;
}
$output = theme('table', $form['header']['#value'], $rows);
$output .= drupal_render($form['submit']);
return $output;
}
The submit hook witch I temporarily use to see the form values
function flash_text_fonts_form_submit($form_id, $form_values) {
$output = "Test<br/>";
foreach($form_values['check_del_font'] as $k => $v) {
$output .= $k.' = '.$v;
if(!$form_values['check_del_font'][$k]) $output .= ' (not selected)'; else $output .= ' (selected)';
$output .= '<br />';
}
$output .= 'Test = '.$form_values['check_del_font']['flash_to_javascript.swf'];
drupal_set_message(t('The new font is saved in: ').$form_values['check_del_font'].'.'.$output);
}
Comments
I am having the same problem
I know this is an old thread, but I was wondering if you ever solved this problem?