/*
* Get form fields along with any stored data
*
- * @param
- * @param string $a Action being performed (l, i, g, ...)
+ * @param string $fid Form identification string
+ * @param integer $recordId form instance ID
+ * @param boolean $ignoreNonInput Do not return non-input fields
*
* @return object Class object
*
*/
- public function getFormWithData($fid, $recordId = false)
+ public function getFormWithData($fid, $recordId = false, $ignoreNonInput = false)
{
// Save current status of get stored data flag
$savedGetStoredDataState = $this->getStoredData;
// Check if there's any priority display fields or fields with selected cost
if (is_array($result['form']) && count($result['form']) > 0) {
- foreach ($result['form'] as $field) {
+ foreach ($result['form'] as $fKey=>$field) {
if ($field['priority_display']['value'] || $field['cost'] > 0) {
$result['hasPriorityField'] = true;
}
if ($field['cost'] > 0) {
$result['totalCost'] += $field['cost'];
}
+ if ($ignoreNonInput && $field['displayOnly']) {
+ unset($result['form'][$fKey]);
+ }
}
}
/* Styles for sorting */
.ui-sortable-helper {
}
-.sortable-handle {
+.glm-custom-sortable-handle {
cursor: pointer;
}
.sort-field-outofsortarea {
*
* This model action does not return, it simply does it's work then calls die();
*
+ * This model looks for a submit parameter of "option2". If that is "fieldsOnly"
+ * then only input fields are included and comments and separators are not included.
+ *
* @param $actionData
*
* @return No return is expected from this model. Content should be output then wp_die();
public function modelAction ($actionData = false)
{
+ // Check if this is a request to only output input fields and ignore comments and such
+ $fieldsOnly = (isset($_REQUEST) && $_REQUEST['option2'] == 'fieldsOnly');
+
switch($_REQUEST['option']) {
case 'displayForm':
'record-id' => $_REQUEST['recordId'],
'parent-form-id' => $_REQUEST['parentFormId'],
'form-data' => $_REQUEST['formData'],
+ 'ignore-non-input' => $fieldsOnly
)
);
}
// Try to retrieve the form
- $formFields = $this->getFormWithData($formId, $recordId);
+ $formFields = $this->getFormWithData($formId, $recordId, $actionData['request']['ignore-non-input']);
// If we received good data
if ( isset($formFields)
</thead>
{if $haveCustomFields}
{foreach $custom_fields as $t}
- <tbody id="field_{$t.id}" class="sort-field-container">
+ <tbody id="field_{$t.id}" class="glm-custom-sort-field-container">
<tr class="FieldRow_{$t.id}">
- <th style="font-weight: bold; text-align: left;" id="DisplayFieldName_{$t.id}" class="sortable-handle">{$t.field_name}</th>
+ <th style="font-weight: bold; text-align: left;" id="DisplayFieldName_{$t.id}" class="glm-custom-sortable-handle">{$t.field_name}</th>
<td style="text-align: left;" id="DisplayFieldTypeDescr_{$t.id}">{$t.field_type_descr}</td>
<td style="text-align: left;" id="DisplayFieldPriority_{$t.id}">{$t.priority_display.name}</td>
<td style="text-align: left;" id="DisplayFieldRequired_{$t.id}">{$t.required.name}</td>
*/
// Hide any custom field options for the field while mousedown
- $('.sortable-handle').mousedown(function() {
+ $('.glm-custom-sortable-handle').mousedown(function() {
$(this).parent().parent().find(".picklist-options-container").css("display","none");
});
- $('.sortable-handle').mouseup(function() {
+ $('.glm-custom-sortable-handle').mouseup(function() {
$(this).parent().parent().find(".picklist-options-container").css("display","table-row");
});
// Make fields tables sortable
var regFieldSortable = $('#FieldsTable_{$fid}').sortable({
- items: '.sort-field-container',
+ items: '.glm-custom-sort-field-container',
cursorAt: { top: -20, left: 10 },
- handle: ".sortable-handle",
+ handle: ".glm-custom-sortable-handle",
start: function ( event, ui ) {
},
stop: function ( event, ui ) {
data: formData,
encode: true,
dataType: 'text'
- })
+ });
}
});