- Create a custom field in the gallery
- Make it a checklist
- Make it required
- Make it searchable
- Edit an item, don't fill that field
- Observe errors when saving
// 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);
}