Jeffrey Kohn - Developer, Cook, Geek

  • Home
  • About Me
  • Blog
    • Sunday Dinners
    • Bacon
    • Beer
  • Recipes
    • Bacon
    • All Recipes
  • Code
  • Photos
  • Contact
Home

Recent Blog Posts

  • Boddingtons
  • Sunday Dinner - April 8, 2012
  • Sunday Dinner - Feb 26, 2012
  • HopCity Happy Hour Premium Ale
  • Coins
  • La Trappe - Quadrupel trappist ale
  • Sunday Dinner - Super Bowl
  • Top 5 pictures from my Flickr profile
  • Lunch?
  • Sunday Dinner - Oct 2
more

Recent Recipes

  • Bacon Whiskey Sour
  • Bacon Whiskey
  • Steak & mushroom pie
  • Oven Roasted Pulled Pork Sandwiches
  • Banana Rum Egg Nog
  • bacon wrapped poutine stuffed chicken
  • Ultimate Ice Cream Sandwich
  • Gambas al Ajillo (Garlic Shrimp)
  • Sufganiyot 2
  • Candied Bacon, Maple Whipped Cream Donuts
more

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

  • cck
  • Drupal
  • hook_form_alter
  • Add new comment

Twitter
Facebook
Flickr

  • home
  • about me
  • blog
  • recipes
  • code
  • photos
  • contact