Collections functions
General functions
Render functions
Theme permission functions
Resource functions

render_field_selector_question()

Description

Renders a metadata field selector

Parameters

ColumnTypeDefaultDescription
$label string label for the field
$name string name of form select
$ftypes array Array of integer field type ids to include. See definitions.php. Will return all types if incorrect value or empty array supplied.
$class string "stdwidth" array CSS class to apply
$hidden boolean false optionally hide the question usng CSS display:none
$current array 0 Current selected value

Return

void

Location

include/render_functions.php lines 3035 to 3064

Definition

 
function render_field_selector_question($label$name$ftypes$class "stdwidth"$hidden false$current 0)
    {
    global 
$lang;
    
$fieldtypefilter "";
    
$parameters = array();

    
// Check only valid field types supplied. An empty array is valid i.e. return all types.
    
$ftypes array_filter($ftypes, function($t) {global $field_types; return is_int($t) && in_array($tarray_keys($field_types));});
        
    if(
count($ftypes)>0)
        {
        
$fieldtypefilter " WHERE type IN (" ps_param_insert(count($ftypes)) . ")";
        
$parameters ps_param_fill($ftypes"i");
        }

    
$fields ps_query("SELECT " columns_in("resource_type_field") . " from resource_type_field " .  (($fieldtypefilter=="")?"":$fieldtypefilter) . " ORDER BY title, name"$parameters"schema");

    echo 
"<div class='Question' id='" $name "'" . ($hidden " style='display:none;border-top:none;'" "") . ">";
    echo 
"<label for='" htmlspecialchars($name) . "' >" htmlspecialchars($label) . "</label>";
    echo 
"<select name='" htmlspecialchars($name) . "' id='" htmlspecialchars($name) . "' class='" $class "'>";
    echo 
"<option value='' selected >" $lang["select"] . "</option>";
    foreach(
$fields as $field)
        {
        
$selected = ($field["ref"] == $current "selected" "");
        echo 
"<option value='{$field['ref']}{$selected}>" lang_or_i18n_get_translated($field['title'],'fieldtitle-') . "</option>";
        }
    echo 
"</select>";
    echo 
"<div class='clearerleft'></div>";
    echo 
"</div>";
    }

This article was last updated 3rd October 2022 13:05 Europe/London time based on the source file dated 22nd September 2022 16:20 Europe/London time.