Wedge

Public area => The Pub => Bug reports => Topic started by: live627 on February 1st, 2019, 12:54 AM

Title: Possible bug with custom fields
Post by: live627 on February 1st, 2019, 12:54 AM
Code: [Select]
// Add them to the form
  foreach ($fields as $field)
  {
- if ($field['type'] == 'checkbox')
+ if ($field['type'] == 'checkbox' && empty($field['searchable']))
  $field['value'] = explode(', ', $field['value']);
 
  // Options...
  $value = isset($_POST['custom_field'][$field['id']]) && (is_array($_POST['custom_field'][$field['id']]) || trim($_POST['custom_field'][$field['id']]) != '') ? $_POST['custom_field'][$field['id']] : '';
 
+ // JTR: preparsecode() corrupts the array by converting it to a string.
+ if (isset($_POST['custom_field'][$field['id']]) && !is_array($_POST['custom_field'][$field['id']]))
- preparsecode($value);
+ preparsecode($value);
 
  // Do the value checks
  if ($field['type'] == 'checkbox')
  {
- foreach ($value as $val)
- if (!in_array($val, $field['options']))
- fatal_error(sprintf($txt['aeva_cf_invalid'], $field['name']));
-
  // Nothing set?
  if (empty($value) && $field['required'])
  fatal_error(sprintf($txt['aeva_cf_empty'], $field['name']));
  elseif (empty($value))
  continue;
 
+ foreach ($value as $val)
+ if (!in_array($val, $field['options']))
+ fatal_error(sprintf($txt['aeva_cf_invalid'], $field['name']));
+
  // Set the proper value
  $value = implode(', ', $value);
  }
Title: Re: Possible bug with custom fields
Post by: Nao on May 11th, 2019, 01:36 PM
Is... that a fix, you posted below? Because your topic says 'possible bug', not 'bug with possible fix'... ;)
You could just as well post a PR..? Or maybe there's one... I must admit, I don't check the git page often.

(As a quick note: I believe the custom field feature for AeMe was written by Dragooon originally, so I'm probably not well versed in it.)