Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 3031 to 3060

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='" escape($name) . "' >" escape($label) . "</label>";
    echo 
"<select name='" escape($name) . "' id='" escape($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 23rd April 2024 09:35 Europe/London time based on the source file dated 17th April 2024 16:25 Europe/London time.