Hi guys,

I created a content type with differents fields ( text, select and checkbox). For the checkbox, I want to allow the admin to decide if an option is checked by default or not.
It exist a default value I can set for the checkbox, but it's not what i'm looking for. I really want to give the admin the oppotunity to check an option (example : Yes, I want to subscribe to your newsletter) by default or not when the content is published.
I supposed I have to create a form alter, but I'm new with that, I don't know what to do. Please help!

Thanks

Comments

voxy’s picture

Anyone?

mikey_p’s picture

Project: Drupal core » Content Construction Kit (CCK)
Version: 6.x-dev » 6.x-2.x-dev
Component: node.module » optionwidgets.module
Priority: Major » Normal

I believe you can set this by visiting the configure page for that field an expanding the default value field set and setting the option there.

voxy’s picture

Hi,
thanks for your answer but I already tried this. It's not what I'm looking for.

voxy’s picture

I fixed my problem.
After spending some times in the code of the module (in the pages.inc of the custom module), I found those lines :

if ($node->field_concours_optin[0]['value']) {
    $form['optin'] = array(
    '#type' => 'checkbox',
    '#title' => $node->field_concours_optin[0]['value'],
    '#prefix' => '<div class="push-down">',
    '#suffix' => '</div>',
  );

the field_concours_optin was the one I wanted to checked by default if I want to. So I created a single checkbox (field_defaultchecked) with 2 values :

0|
1| Check by default

in the admin, and I added these lines :

    if ($node->field_defaultchecked[0]['value']) {
    $form['optin'] = array(
    '#default_value' => 1,   // CHECKED BY DEFAULT
    '#type' => 'checkbox',
    '#title' => $node->field_concours_optin[0]['value'],
    '#prefix' => '<div class="push-down">',
    '#suffix' => '</div>',
	
  );
  }

AND IT WORKS!!!

voxy’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.