function data_taxonomy_tagging_form in Data 6
Form callback for tagging.
1 string reference to 'data_taxonomy_tagging_form'
- data_taxonomy_views_handler_field_form::render in data_taxonomy/
views/ data_taxonomy_views_handler_field_form.inc - Render form.
File
- data_taxonomy/
data_taxonomy.module, line 188 - Hooks and API functions for Data Node module.
Code
function data_taxonomy_tagging_form(&$form_state, $vid, $id, $table_name, $path, $args) {
$access = user_access('edit data taxonomy relations');
$form = array(
'#theme' => 'data_taxonomy_tagging_form',
);
$form['vid'] = array(
'#type' => 'hidden',
'#value' => $vid,
'#access' => $access,
);
$form['id'] = array(
'#type' => 'hidden',
'#value' => $id,
'#access' => $access,
);
$form['table_name'] = array(
'#type' => 'hidden',
'#value' => $table_name,
'#access' => $access,
);
$form['path'] = array(
'#type' => 'hidden',
'#value' => $path,
'#access' => $access,
);
$form['args'] = array(
'#type' => 'hidden',
'#value' => implode('&', $args),
'#access' => $access,
);
$result = db_query('SELECT td.tid, td.name, td.vid FROM {term_data} td JOIN {data_taxonomy} dt ON td.tid = dt.tid WHERE dt.data_table_name = "%s" AND dt.id = %d AND td.vid = %d', $table_name, $id, $vid);
$tags = $terms = array();
while ($term = db_fetch_object($result)) {
$tags[$term->tid] = $term->name;
$terms[$term->tid] = $term;
}
$form['tags'] = array(
'#type' => 'textfield',
'#default_value' => implode(', ', $tags),
'#autocomplete_path' => 'taxonomy/autocomplete/' . $vid,
'#id' => "edit-tags-data-taxonomy-{$vid}-{$id}",
'#access' => $access,
);
// Ensure our path gets rewritten. We don't use url() here because we're
// not interested in rewrites to parts of the request other than $_GET['q'].
$ajax_path = 'data-taxonomy/ajax-save';
if (function_exists('custom_url_rewrite_outbound')) {
$original_path = $ajax_path;
$options = array();
custom_url_rewrite_outbound($ajax_path, $options, $original_path);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#access' => $access,
// AHAH stack: We need to assign our submit button its own ID as auto
// assignment will quickly lead to a situation where our AJAX form button
// has a different ID from the original.
'#id' => "edit-submit-data-taxonomy-{$vid}-{$id}",
'#ahah' => array(
'path' => $ajax_path,
'wrapper' => "data-taxonomy-tags-{$vid}-{$id}",
'method' => 'replace',
'effect' => 'none',
),
);
// Pass on key elements for theming.
$form['#terms'] = $terms;
$form['#path'] = $path;
$form['#args'] = $args;
if ($access) {
$form['#edit'] = l(t('Edit'), $_GET['q'], array(
'fragment' => 'data-taxonomy-edit',
'attributes' => array(
'class' => 'data-taxonomy-edit',
),
));
}
$form['#vocab'] = taxonomy_vocabulary_load($vid);
return $form;
}