Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

render_new_node_record()

Description

Renders HTML for adding a new node record in the database

Parameters

ColumnTypeDefaultDescription
$form_action string Set the action path of the form
$is_tree boolean Set to TRUE if the field is category tree type
$parent integer 0 ID of the parent of this node
$node_depth_level integer 0 When rendering for trees, we need to know how many levels deep we need to render it
$parent_node_options array array Array of node options to be used as parent for new records

Return

void

Location

include/node_functions.php lines 538 to 630

Definition

 
function render_new_node_record($form_action$is_tree$parent 0$node_depth_level 0, array $parent_node_options = array())
    {
    global 
$baseurl_short$lang;
    if(!isset(
$is_tree))
        {
        
trigger_error('$is_tree param for render_new_node_record() must be set to either TRUE or FALSE!');
        }

    if (
trim($form_action)=="")
        {
        
trigger_error('$form_action param for render_new_node_record() must be set and not be an empty string!');
        }

    
// Render normal fields first then go to tree type
    
if(!$is_tree)
        {
        
?>
        <tr id="new_node_ echo $parent?>_children">
            <td>
                <input type="text" class="stdwidth" name="new_option_name" form="new_option" value="">
            </td>
            <td> </td>
            <td>
                <div class="ListTools">
                    <form id="new_option" method="post" action=" echo $form_action?>">
                         generateFormToken("new_option"); ?>
                        <button type="submit" onClick="AddNode( echo $parent?>); return false;"> echo $lang['add']; ?></button>
                    </form>
                </div>
            </td>
        </tr>
        

        
return;
        }

    
// Trees only
    
?>
    <table id="new_node_ echo $parent?>_children" cellspacing="0" cellpadding="5">
        <tbody>
            <tr>
            
            
// Indent node to the correct depth level
            
$i $node_depth_level;
            while(
$i)
                {
                
$i--;
                
?>
                <td class="backline" width="10">
                    <img width="11" height="11" hspace="4" src=" echo $baseurl_short?>gfx/interface/sp.gif">
                </td>
                
                
}
                
?>
                <td class="backline" width="10">
                    <img width="11" height="11" hspace="4" src=" echo $baseurl_short?>gfx/interface/sp.gif">
                </td>
                <td>
                    <input type="text" name="new_option_name" form="new_node_ echo $parent?>_option" value="">
                </td>
                <td>
                    <select class="node_parent_chosen_selector" name="new_option_parent" form="new_node_ echo $parent?>_option">
                        <option value="">Select parent</option>
                    
                    
foreach($parent_node_options as $node)
                        {
                        
$selected '';
                        if(!(
trim($parent)=="") && $node['ref'] == $parent)
                            {
                            
$selected ' selected';
                            }
                        
?>
                        <option value=" echo $node['ref']; ?>" echo $selected?>> echo htmlspecialchars($node['name']); ?></option>
                        
                        
}
                        
?>
                    </select>
                </td>
                <td>
                    <div class="ListTools">
                        <form id="new_node_ echo $parent?>_option" method="post" action=" echo $form_action?>">
                             generateFormToken("new_node_{$parent}_option"); ?>
                            <button type="submit" onClick="AddNode( echo $parent?>); return false;"> echo $lang['add']; ?></button>
                        </form>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>

    
    
return;
    }

This article was last updated 29th November 2020 04:35 Europe/London time based on the source file dated 13th November 2020 16:50 Europe/London time.