Recent Blog Posts
Increasing number of values for a CCK field
Dec
16
2010
<?php
function mymodule_form_alter(&$form, &$form_state, $form_id)
{
// check if we are in 'content_field_edit_form' and the
// cck field we are editing is called myfield'
if ($form_id == 'content_field_edit_form' && $form['#field']['field_name'] == 'field_myfield') {
$options = array();
$options[1] = 'Unlimited';
$options[0] = 1;
for ($i = 2; $i <= 10; $i++ ) {
$options[$i] = $i;
}
// the new number of values you want to have
$options[24] = 24;
$form['field']['multiple']['#options'] = $options;
}
}
?>The only problem with this is that now you have X number of values displaying. It would be nice to have it like the unlimited and using ahah to add fields until the desired value is reached. I will put that in my next post