I have made a custom node from scratch, not using CCK, because I need more control over the node than CCK can give me.

In the Add/Edit form I have a list of checkboxes. Using hook_insert (and hook_update) I want to save the selections. And in the hook_load I want to retrieve this.

How do I do this?

relevant code in hook_form:

  $display_options = array(
    'display_address' => t('Display my address'),
    'display_email' => t('Display my email'),
    'display_phone' => t('Display my home phone number')
  );
  $form['display_settings'] = array(
    '#title' => t('Website Display Options'),
    '#type' => 'checkboxes',
    '#description' => t('Allow web visitors to see your personal address information. '),
    '#options' => $display_options,
    '#weight' => 10,
  );

Comments

amitaibu’s picture

What options do you need that CCK doesn't give you?
---
gizra.com - where cool software developers meet geek fashion designers

mjvandermeulen’s picture

What options do you need that CCK doesn't give you?

I need to connect to the civiCRM database to display fields from that database.
I need to add checkboxes so owners of the node can choose to display certain fields or not.

I don't think I can use CCK for this.

It's all up and running now. I wrote a custom node module from scratch, using the drupal Pro book. It was a lot of work though.

rosenhauer’s picture

I'm having the same sort of issues could you share your solution.

Dave

rosenhauer’s picture

define the field as follows:

$services = array(
'Sales' =>t('Still Photography'),
'Service' =>t('Videography'),
);

$form['services'] = array(
'#type' => 'checkboxes',
'#title' => 'Last Name',
'#default_value' => explode(",", $node->services),
'#options' => $services,
'#required' => false,
);

Then in the SQL use;

$servicesstring = implode(",", $node->services);

as the value to save into the DB.

Hope this helps someone else.
Dave

bharat83’s picture

Is your solution working. Please let me know what solution you applied for it