// Field Type
'field_type' => array(
'field' => 'field_type',
- 'type' => 'list',
- 'list' => $this->config['custom_field_types'],
+ 'type' => 'text',
'required' => true,
'use' => 'a'
),
*/
public function entryPostProcessing($r, $a)
{
+
+ // Get field type description from ini file.
+ $r['field_type_descr'] = $this->config['custom_field_type'][$r['field_type']];
+
return $r;
}
;
; Place any static configuration parameters here.
;
+
+
+;
+; Custom Field Types
+;
+custom_field_type['text'] = 'Single Line Text Field'
+custom_field_type['textarea'] = 'Multi-Line Text Area'
+custom_field_type['checkbox'] = 'Checkbox'
+; custom_field_type['integer'] = 'Integer Number'
+; custom_field_type['float'] = 'Floating Point number'
if (!is_array($customField) || !$customField['status']) {
echo "0";
} else {
+
+ // Add description for the selected field type
+ $customField['fieldData']['field_type_descr'] = $this->config['custom_field_type'][$customField['fieldData']['field_type']];
+
+ // Produce HTML for the new field
$viewFile = 'admin/ajax/newField.html';
$newFieldHtml = $this->generateHTML($customField, $viewFile);
echo $newFieldHtml;
}
- $where .= " AND fid = '$fid' ";
+ // Build custom field types array for building picklist
+ $fieldTypes = array();
+ foreach ($this->config['custom_field_type'] as $typeKey=>$typeVal) {
+ $fieldTypes[$typeKey] = array('type_name' => $typeKey, 'prompt' => $typeVal);
+ }
// Get list of Custom Fields
- $custom_fields = $this->getList( $where );
+ $where .= " AND fid = '$fid' ";
+ $custom_fields = $this->getList( $where, false, true);
if ( isset($custom_fields) && $custom_fields && count( $custom_fields ) > 0 ) {
$haveCustomFields = true;
'settingsUpdated' => $settings_updated,
'settingsUpdateError' => $settings_update_error,
'custom_fields' => $custom_fields,
- 'field_types' => $this->config['custom_field_types'],
+ 'fieldTypes' => $fieldTypes,
'haveCustomFields' => $haveCustomFields,
'fid' => $fid,
'glm_action' => $glm_action
/**
* Return HTML for a custom fields form segment
*
- * @param $content string Any supplied content. Form will be appended to this
- * @param $fid string Unique ID of form
- * @param $recordId integer Optional ID for instance of this form (generally the ID of the associated record)
- * If this is 0 then it's assumed this is a new form with no existing data.
- * @param $submitId string Optional ID of the submit button for the form this will be part of.
- * @param $formData array Optional array of data used to populate form (Not sure we're going to keep this)
+ * @param $content string Any supplied content. Form will be appended to this
+ * @param $fid string Unique ID of form
+ * @param $recordId integer Optional ID for instance of this form (generally the ID of the associated record)
+ * If this is 0 then it's assumed this is a new form with no existing data.
+ * @param $parentFormId string Optional ID of the submit button for the form that will have these custom fields added.
+ * This is used to block submit (if possible) for that form while there's still required custom fields.
+ * @param $formData array Optional array of data used to populate form (Not sure we're going to keep this)
*
* returns an array with status and HTML for editing the form.
*/
{* A single line for the custom fields edit table *}
- <tr id="FieldRow_{$fieldData.id}">
+ <tr class="FieldRow_{$fieldData.id}">
<td>{$fieldData.field_name}</td>
- <td id="editFieldType_{$fieldData.id}">{$fieldData.field_type.name}</td>
+ <td id="editFieldType_{$fieldData.id}">{$fieldData.field_type_descr}</td>
<td>{$fieldData.required.name}</td>
<td>
<!-- <div class="glmCustomFieldsEditFieldButton button button-secondary glm-button-small" data-fieldID="{$fieldData.id}" data-fieldName="{$fieldData.field_name|escape:'html'}" data-fieldPrompt="{$fieldData.field_prompt|escape:'html'}" data-fieldType="{$fieldData.field_type.name|escape:'html'}" data-adminSearch="{$fieldData.admin_search.value}" data-required="{$fieldData.required.value}">Edit</div>
<div class="{$fieldData.fid}_DeleteFieldButton button button-secondary glm-button-small" data-fieldID="{$fieldData.id}">Delete</div>
</td>
</tr>
- <tr><td colspan="4" style="padding-left: 2rem;">Prompt: {$fieldData.field_prompt}</td></tr>
\ No newline at end of file
+ <tr class="FieldRow_{$fieldData.id}"><td colspan="4" style="padding-left: 2rem;">Prompt: {$fieldData.field_prompt}</td></tr>
\ No newline at end of file
<td>
<select id="{$fid}_NewFieldType" name="field_type">
<option value=""></option>
- <option value="text">Single Line Text Field</option>
- <option value="textarea">Multi-line Text Area</option>
- <option value="checkbox">Checkbox</option>
-<!--
- <option value="integer">Integer Field</option>
- <option value="float">Floating Point Number Field</option>
- -->
+ {foreach $fieldTypes as $type}
+ <option value="{$type.type_name}">{$type.prompt}</option>
+ {/foreach}
</select>
</td>
</tr>
<tr class="FieldRow_{$t.id}">
<th style="font-weight: bold;">{$t.field_name}</th>
<td id="editFieldType_{$t.id}">
- {$t.field_type.name}
+ {$t.field_type_descr}
</td>
<td>
{$t.required.name}