SproutCMS

This is the code documentation for the SproutCMS project

class JsonForm

Processes forms using configuration stored in a JSON file which specifies database columns, their HTML input fields,
and validation rules.
A generic implementation which should work for most cases is found in ManagedAdminController::_getEditForm
(generates the form) and Controller::saveJsonData (saves the POST submission)

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2024-11-24
**/
class NewClassName extends JsonForm {
    
    /**
    * Modify a JSON form config to change the 'required' status of a particular field
    * This implements {@see JsonForm::makeOptional} and {@see JsonForm::makeRequired}
    **/
    protected function changeFieldRequired (array $conf, string $field_name, bool $required) {
        // Method code goes here
    }
    
    /**
    * Modify a JSON form config to make a particular field required
    **/
    public function makeRequired (array $conf, string $field_name) {
        // Method code goes here
    }
    
    /**
    * Modify a JSON form config to make a particular field optional
    **/
    public function makeOptional (array $conf, string $field_name) {
        // Method code goes here
    }
    
    /**
    * Replace magic strings in &quot;args&quot; arrays with various metadata values
    * 
    * Replacements:
    *     %%       The current record id
    **/
    private function argReplace (array $args, array $metadata) {
        // Method code goes here
    }
    
    /**
    * Collates a single field's $_POST data for INSERT/UPDATE queries, and performs validation
    **/
    protected function collateFieldData (array $field_defn, string $input, array $metadata, Validator $valid, array $data) {
        // Method code goes here
    }
    
    /**
    * Extract field defns from a list (which may include groups)
    **/
    public function flattenGroups (array $items) {
        // Method code goes here
    }
    
    /**
    * Collates POST data using specified config options
    **/
    public function collateData (array $conf, string $mode, Validator $validator, int $item_id) {
        // Method code goes here
    }
    
    /**
    * Set a parameter for fields to be a specific value, for one or more columns
    **/
    public function setParameterForColumns (array $items, array $columns, string $key, string $val) {
        // Method code goes here
    }
    
    /**
    * Renders the input for a field definition pulled from a JSON file
    **/
    public function renderField (array $field, string $name_prepend, array $metadata) {
        // Method code goes here
    }
    
    /**
    * Render a tab item, which may be a field, heading, html block, etc
    **/
    public function renderTabItem (array $item, string $for, int $id, array $data, array $errors, string $name_prepend) {
        // Method code goes here
    }
    
    /**
    * Expands item definitions for a field pulled from JSON
    **/
    public function expandItemDefns (array $field, array $metadata) {
        // Method code goes here
    }
    
    /**
    * Loads autofill_list data for use on a view
    **/
    public function loadAutofillListData (array $conf, string $local_table_name, int $local_record_id, array $conditions) {
        // Method code goes here
    }
    
    /**
    * Determine the auto-generated default values for an autofill-list
    * 
    * Defaults:
    *     joiner_local_col        Singular of local table name + '_id'
    *     joiner_foreign_col      Singular of the foreign_table option + '_id'
    *     foreign_label_col       'name'
    *     reorder                 false
    **/
    public function autofillOptionDefaults (array $auto, string $local_table_name) {
        // Method code goes here
    }
    
    /**
    * Loads multiedit data for use on a view
    **/
    public function loadMultiEditData (array $conf, string $default_link, int $record_id, array $conditions) {
        // Method code goes here
    }
    
}
?>