Skip to content

Instantly share code, notes, and snippets.

@opi
Created February 22, 2012 13:23
Show Gist options
  • Save opi/1885165 to your computer and use it in GitHub Desktop.
Save opi/1885165 to your computer and use it in GitHub Desktop.
D6: Alter cck multiple value field. Not really sure this is the good way.
<?php
/**
* Implementation of hook_form_alter().
*/
function mymodule_form_alter(&$form, $form_state, $form_id) {
// Appelé la 1ere fois, sur node/add/mycontenttype
if($form_id == 'mycontenttype_node_form') {
foreach($form['field_my_field'] as $k => $v) {
if (is_numeric($k)) {
$form['field_my_field'][$k]['#autocomplete_path'] = 'my-autocomplete-path';
}
}
}
// appelé a chaque "Add another item" sur field_my_field
elseif ($form_id == 'content_add_more_js' && isset($form['field_my_field'])) {
foreach($form['field_my_field'] as $k => $v) {
if (is_numeric($k)) {
$form['field_my_field'][$k]['#autocomplete_path'] = 'my-autocomplete-path';
}
}
}
} // mymodule_form_alter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment