public function processFieldInterface($fieldname, $prefix) { switch ($fieldname) { case 'params': $options = array(); $toDelete = array_get($_REQUEST, $prefix . 'options_delete', array()); foreach ($_REQUEST[$prefix . 'option_ids'] as $i => $id) { if (!in_array($id, $toDelete)) { $o = trim($_REQUEST[$prefix . 'option_values'][$i]); if ($o !== '') { $options[] = $o; } } } $this->setValue('params', array('options' => $options)); break; default: return parent::processFieldInterface($fieldname, $prefix); } }
function processFieldInterface($name, $prefix) { switch ($name) { case 'members': $this->_members = array(); $this->_members_to_set = $_POST[$prefix . $name]; break; default: return parent::processFieldInterface($name, $prefix); } }
/** * Process an interface for CONFIGURING this custom field * @param string $fieldname * @param string $prefix */ public function processFieldInterface($fieldname, $prefix = '') { switch ($fieldname) { case 'allow_multiple': $this->setValue('allow_multiple', !empty($_REQUEST[$prefix . $fieldname])); break; case 'params': $val = array(); $val['allow_note'] = !empty($_REQUEST[$prefix . 'allow_note']); $val['allow_blank_year'] = !empty($_REQUEST[$prefix . 'allow_blank_year']); $val['regex'] = array_get($_REQUEST, $prefix . 'regex', ''); $this->setValue($fieldname, $val); // Also process the options for select fields: if (!empty($_REQUEST[$prefix . 'option_ids'])) { $newOptions = $updateOptions = $deleteOptions = array(); foreach ($_REQUEST[$prefix . 'option_ids'] as $rank => $optionID) { $value = $_REQUEST[$prefix . 'option_values'][$rank]; if ($optionID) { // Update if (in_array($optionID, array_get($_REQUEST, $prefix . 'options_delete', array()))) { $deleteOptions[] = $GLOBALS['system']->getDBObject('custom_field_option', $optionID); } else { $updateOptions[$optionID] = $GLOBALS['system']->getDBObject('custom_field_option', $optionID); $updateOptions[$optionID]->setValue('value', $value); $updateOptions[$optionID]->setValue('rank', $rank); } } else { // New if (strlen($value)) { $newOption = new Custom_Field_Option(); $newOption->setValue('value', $value); $newOption->setValue('rank', $rank); $newOptions[] = $newOption; } } } $this->_tmp['new_options'] = $newOptions; $this->_tmp['update_options'] = $updateOptions; $this->_tmp['delete_options'] = $deleteOptions; } break; default: parent::processFieldInterface($fieldname, $prefix); break; } }
/** * Process an interface for CONFIGURING this note template * @param string $fieldname * @param string $prefix */ public function processFieldInterface($fieldname, $prefix = '') { switch ($fieldname) { case 'fields': $ranks = array_flip(array_get($_REQUEST, 'index', array())); $i = 0; while (isset($_REQUEST['fields_' . $i . '_fieldtype'])) { $prefix = 'fields_' . $i . '_'; if (!empty($_REQUEST[$prefix . 'delete'])) { $this->_fields_to_delete[] = $_REQUEST[$prefix . 'delete']; } else { if (!empty($_REQUEST['fields_' . $i . '_fieldtype'])) { $fieldObj = new Note_Template_Field($_REQUEST[$prefix . 'id']); $fieldObj->setValue('rank', $ranks[$i]); if ($_REQUEST[$prefix . 'fieldtype'] == 'custom') { // Set the customfieldid only $fieldObj->processFieldInterface('customfieldid', $prefix); } else { // Set everything except the customfieldid $fieldObj->processForm($prefix); $fieldObj->setValue('customfieldid', NULL); } if ($fieldObj->getValue('customfieldid') || $fieldObj->getValue('label')) { $this->_fields[] = $fieldObj; } } } $i++; } break; default: parent::processFieldInterface($fieldname, $prefix); break; } }