Hi, I'm really new to drupal. So my question maybe easy to you. But I really need some help. Any feedback is really appreciated.
Ok, I use drupal4.6, in the event module: I have:
$when .= form_select('', 'month', $month, $months);
$when .= form_select('', 'day', $day, $days);
$when .= form_select('', 'year', $year, $years);
So the three drop down will appear in same row. very nicely this way.
Now I need to upgrade to drupal4.7(beta3), then I need to use array instead of "form_select"
it goes like this:
$form['month'] = array(
'#type' => 'select',
'#title' => t('month'),
'#default_value' => $month,
);
$form['day'] = array(
'#type' => 'select',
'#title' => t('day'),
'#default_value' => $day,
);
$form['month'] = array(
'#type' => 'select',
'#title' => t('year'),
'#default_value' => $year,
);
But the problem is each dropdown goes to different row now. Because
is added to each of the drop down.
What can I do to get this solved?
Comments
hmm...I think I know
hmm...I think I know why...need use make up?
#prefix, #suffix or #type => date
First of all we now have a date form element. Second,
note that because $form['date']['#tree'] is FALSE (per default) you won't get edit[date][month] but edit[month] which is just what you want.
Finally, instead of prefix/suffix you may attach a #theme => 'foo' to $form['date'] and then you can do whatever you want in theme_foo.
--
My developer blog. | The news is Now Public | Ask not what Drupal can do for you -- ask what you can do for Drupal.
--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.
wow...thanks so much
Thanks so much for your reply...! I'll try this out!
Hmmm....I tried the date
Hmmm....I tried the date type like this:
$form['due_date'] = array('#type' => 'date','#title' => 'Due Date');
$form['due_date']['month'] = array(
'#default_value' => $months,
);
$form['due_date']['day'] = array(
'#default_value' => $days,
);
$form['due_date']['year'] = array(
'#title' => t('year'),
'#default_value' => $years,
);
It gives me nice three drop down month/day/year. But the problem is it only default to current date, not the default date I specified in the $day, $month, $year....do you know what data format shoudl be used here for the '#default_value' ?
And also when do the error check. I use:
form_set_error("due_date", t("Due date must be at least 10 business days from today."));
But seems not working too......:-(
Really appreciate for your feedback!!