This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

how to validate radiobuttons the best way in 4.6?

Hi,

I'm making a module for Drupal 4.6, and i have some trouble with validation.
I know 4.7 is better for forms, but i'm obliged to use 4.6 for this project.

The way i see it, there should be 2 ways to validate radiobuttons:

$sem_options = array(1 => "1st semester", 2 => "2nd semester");
$output .= form_radios(t('Semester'), 'semesterID', $node->semesterID , $sem_options, '', TRUE, NULL);

This is the code i have now, and the last TRUE sets the $required parameter to true.
However, when i submit a new node and select none of the 2 radiobuttons, the node gets submitted anyway and no error is triggered.

Then i thought i could set the $required to FALSE and check in the hook_validate() if a radiobutton was selected.

if($node->semesterID == NULL){
  form_set_error('semesterID', t('No semester selected.'));
}

This code does trigger an error when none is selected, but now i have the following weird behaviour:
When i go to 'create content' to make a new node, the validation already gets triggered before i submitted anything, and there's already an error displayed 'No semester selected', even though i didn't even had the change to select anything in the first place...

Does anyone know the best way to solve this issue?
I've searched on the forums and the handbooks, but all i find is 4.7 FormsAPI stuff, which is useless in my case

upload chinese filename attachment

hi all,
I had a problem when i post a new blog(news,page,blog,book). If the new blog had an attachment with chinese file name, there were two situations:
1. The blog was uploaded successfully, but the file name of attachment in the target directory wasn't chinese file name, and this file can't be downloaded.
2. The blog wasn't uploaded successfully,there was an error occurred,the detail information is "an error occurred, unspecified error". These errors occurred only if the attachment file had a chinese file name and this file name was too long.

CCk links

Hi guys, this is pretty straightforward question: how do I get the url of a custom type field when using cck?

Currently I'm using

<?php print $field_url[0][view]?>

With no results whatsoever.

Removing Form Elements From Other Modules

Hello I'm working in Drupal 4.6. I'm building an in and out office module for our intranet. I'm new to Drupal but not new to PHP. At any rate I'm wondering if someone can point me in the right direction. I need to know what function/functions to add to hook_form() or other hook to get the "Scheduler" form element out of the road and secondly how to make the "title" a hidden field with a predetermined value.

Thanks for your help

Do you have to use mktime to store Date form type?

I have a date form element in a new module, have two questions:

Form element:

  $form['review']['proceduredate'] = array(
    '#type' => 'date', 
    '#title' => t('Date you had the procedure'), 
    '#default_value' => $node->proceduredate,
    );

When I insert this into my table with a int(11) field called "proceduredate" - I'm using mktime, but is this necessary?

Module: "insert_block" Block list

I have a few questions on the insert_block module if someone could help me?

Does anyone have a list of the names needed for the "insert_block" module?

[block:<name of module>=<delta of block>]

I'd like to get a list of the names of blocks. Is it the same as they appear in the www.example.com/admin/block page? e.g. [block:Recent blog posts], [block:Recent comments]

Also, what is a delta?

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions