private static function setCustomData($objectName, $field_id, $value, $id)
 {
     $v = $value;
     /**
      * Convert value array from
      *   value_a => 1
      *   value_b => 1
      *
      * To
      *   [] => value_a
      *   [] => value_b
      *
      */
     if (CRM_Civirules_Utils_CustomField::isCustomFieldMultiselect($field_id) && is_array($value)) {
         $all_ones = true;
         foreach ($value as $i => $j) {
             if ($j != 1) {
                 $all_ones = false;
             }
         }
         if ($all_ones) {
             $v = array();
             foreach ($value as $i => $j) {
                 $v[] = $i;
             }
         }
     }
     self::$customValues[$field_id][$id] = $v;
 }
 /**
  * Overridden parent method to build form
  *
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->add('hidden', 'rule_condition_id');
     $this->add('select', 'entity', ts('Entity'), $this->getEntityOptions(), true);
     $this->add('select', 'field', ts('Field'), $this->getFields(), true);
     $this->assign('entities', $this->getEntities());
     $this->assign('custom_field_multi_select_html_types', CRM_Civirules_Utils_CustomField::getMultiselectTypes());
 }
 /**
  * Returns an array of value when the custom field is a multi select
  * otherwise just return the value
  *
  * @param $custom_field_id
  * @param $value
  * @return mixed
  */
 protected function convertMultiselectCustomfieldToArray($custom_field_id, $value)
 {
     if (CRM_Civirules_Utils_CustomField::isCustomFieldMultiselect($custom_field_id)) {
         $value = trim($value, CRM_Core_DAO::VALUE_SEPARATOR);
         $value = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
     }
     return $value;
 }