CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Problems creating checkbox custom field through civicrm_custom_field_create()
Pages: [1]

Author Topic: Problems creating checkbox custom field through civicrm_custom_field_create()  (Read 918 times)

vs

  • Guest
Problems creating checkbox custom field through civicrm_custom_field_create()
January 11, 2010, 07:17:22 am
Hi there!

I'm trying to create new custom field using code:
Code: [Select]
$params = array (
'custom_group_id' => 16,
'label'           => 'Test Label',
'html_type'       => 'CheckBox',
'data_type'       => 'String',
'is_active'       => 1,
'text_length'     => 255,
'note_columns'    => 60,
'note_rows'   => 4,
'option_label'    => array('Test Label'),
'option_value'    => array(1)
);
$customField =& civicrm_custom_field_create($params);

Field creates, but it is not active by default. In civicrm_custom_field table in 'is_active' field it has value 1, but in civicrm_option_value it has 'is_active' value 0.

How can i solve this problem? I haven't find this in documentation ( http://wiki.civicrm.org/confluence/display/CRMUPCOMING/Custom+Data+Group+and+Custom+Field+APIs#CustomDataGroupandCustomFieldAPIs-civicrmcustomfieldcreate%28%24params%29 )

Thanks!

vs

  • Guest
Re: Problems creating checkbox custom field through civicrm_custom_field_create()
January 13, 2010, 06:33:05 am
Hey, guys! I need your help! : )

Sunil

  • I post frequently
  • ***
  • Posts: 131
  • Karma: 23
  • The community around a product more important than the product itself?
    • CiviCRM
Re: Problems creating checkbox custom field through civicrm_custom_field_create()
January 13, 2010, 07:28:30 am
hi
Try One of the below ...
Code: [Select]
$params = array (
'custom_group_id' => 16,
'label'           => 'Test Label-two',
'html_type'       => 'CheckBox',
'data_type'       => 'String',
'is_active'       => 1,
'text_length'     => 255,
'note_columns'    => 60,
'note_rows'   => 4,
'option_label'    => array('Test Label-two-sub'),
'option_value'    => array(1),
'option_weight'   => array(1),
'option_status'   => array(1),
);

$params = array ('custom_group_id' => 16,
                 'label'           => 'PriceMufdlti',
                 'html_type'       => 'Multi-Select',
                 'data_type'       => 'String',
                 'weight'          => 4,
                 'is_required'     => 1,
                 'is_searchable'   => 0,
                 'is_active'       => 1,
                 'option_label'    => array( 'MultiLabel1','MultiLabel2'),
                 'option_value'    => array( 10, 20 ),
                 'option_weight'   => array( 1, 2),
                 'option_status'   => array( 1, 1),
                 );

You missed with
option_status  => Active
option_weight => Order

Hth
Sunil
The community around a product more important than the product itself?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Problems creating checkbox custom field through civicrm_custom_field_create()

This forum was archived on 2017-11-26.