| 1 |
<?php |
<?php |
| 2 |
// $Id: taxonomy_other.module,v 1.1.2.4 2008/07/28 20:23:49 rellis Exp $ |
// $Id: taxonomy_other.module,v 1.1.2.5 2008/08/06 23:07:13 rellis Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 143 |
// Add a specific weight for the select list, so we can make the text field follow immediately after. |
// Add a specific weight for the select list, so we can make the text field follow immediately after. |
| 144 |
$form['taxonomy'][$vid]['#weight'] = $form['taxonomy'][$vid]['#weight'] += 0.1 * $vid; |
$form['taxonomy'][$vid]['#weight'] = $form['taxonomy'][$vid]['#weight'] += 0.1 * $vid; |
| 145 |
|
|
| 146 |
|
// Handle preview. |
| 147 |
|
if (!empty($form_state['clicked_button']['#post']['taxonomy']['taxonomy_other_' . $vid])) { |
| 148 |
|
$taxonomy_other = $form_state['clicked_button']['#post']['taxonomy']['taxonomy_other_' . $vid]; |
| 149 |
|
$form['taxonomy'][$vid]['#default_value'] = 'taxonomy_other'; |
| 150 |
|
} |
| 151 |
|
|
| 152 |
// Add the text field. |
// Add the text field. |
| 153 |
$form['taxonomy']['taxonomy_other_' . $vid] = array( |
$form['taxonomy']['taxonomy_other_' . $vid] = array( |
| 154 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 155 |
'#size' => 128, |
'#size' => 128, |
| 156 |
'#title' => t('Other %title', array('%title' => $form['taxonomy'][$vid]['#title'])), |
'#title' => t('Other %title', array('%title' => $form['taxonomy'][$vid]['#title'])), |
| 157 |
'#id' => 'taxonomy-other-' . $vid, |
'#id' => 'taxonomy-other-' . $vid, |
| 158 |
|
'#default_value' => empty($taxonomy_other) ? '' : $taxonomy_other, |
| 159 |
'#description' => t('Add your own category.'), |
'#description' => t('Add your own category.'), |
| 160 |
'#weight' => $form['taxonomy'][$vid]['#weight'] + 0.01, |
'#weight' => $form['taxonomy'][$vid]['#weight'] + 0.01, |
| 161 |
); |
); |