Exemplo n.º 1
0
/**
 * displays an edit field for a field attribute
 * 
 * @param string $field name of the field
 * @return array contains parameters to use in instantiating the xnau_FormElement object
 */
function PDb_get_edit_field_type($field)
{
    switch ($field) {
        // small integer fields
        case 'id':
            return array('type' => 'hidden');
        case 'order':
            return array('type' => 'drag-sort');
        case 'admin_column':
        case 'display_column':
            return array('type' => 'text', 'attributes' => array('class' => 'digit'));
            // all the booleans
        // all the booleans
        case 'persistent':
        case 'sortable':
        case 'CSV':
        case 'signup':
        case 'readonly':
            return array('type' => 'checkbox', 'options' => array(1, 0));
            // field names can't be edited
        // field names can't be edited
        case 'name':
            return array('type' => 'text', 'attributes' => array('readonly' => 'readonly'));
            // all the text-area fields
        // all the text-area fields
        case 'values':
        case 'help_text':
            return array('type' => 'text-area');
            // drop-down fields
        // drop-down fields
        case 'form_element':
            // populate the dropdown with the available field types from the xnau_FormElement class
            return array('type' => 'dropdown', 'options' => array_flip(PDb_FormElement::get_types()) + array('null_select' => false));
        case 'validation':
            return array('type' => 'dropdown-other', 'options' => array(__('Not Required', 'participants-database') => 'no', __('Required', 'participants-database') => 'yes', __('Email', 'participants-database') => 'email-regex', 'CAPTCHA' => 'captcha', 'null_select' => false), 'attributes' => array('other' => 'regex/match'));
        case 'group':
            // these options are defined on the "settings" page
            return array('type' => 'dropdown', 'options' => Participants_Db::get_groups('name', 'internal') + array('null_select' => false));
        case 'link':
        case 'title':
        default:
            return array('type' => 'text');
    }
}