DropdownTranslation::showForm PHP Method

showForm() public method

Display translation form
public showForm ( $ID, $options = [] )
$ID field (default -1)
$options array
    function showForm($ID = -1, $options = array())
    {
        global $CFG_GLPI;
        if (isset($options['parent']) && !empty($options['parent'])) {
            $item = $options['parent'];
        }
        if ($ID > 0) {
            $this->check($ID, READ);
        } else {
            $options['itemtype'] = get_class($item);
            $options['items_id'] = $item->getID();
            // Create item
            $this->check(-1, CREATE, $options);
        }
        $rand = mt_rand();
        $this->showFormHeader($options);
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Language') . "</td>";
        echo "<td>";
        echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>";
        echo "<input type='hidden' name='itemtype' value='" . get_class($item) . "'>";
        if ($ID > 0) {
            echo "<input type='hidden' name='language' value='" . $this->fields['language'] . "'>";
            echo Dropdown::getLanguageName($this->fields['language']);
        } else {
            $rand = Dropdown::showLanguages("language", array('display_none' => false, 'value' => $_SESSION['glpilanguage']));
            $params = array('language' => '__VALUE__', 'itemtype' => get_class($item), 'items_id' => $item->getID());
            Ajax::updateItemOnSelectEvent("dropdown_language{$rand}", "span_fields", $CFG_GLPI["root_doc"] . "/ajax/updateTranslationFields.php", $params);
        }
        echo "</td><td colspan='2'>&nbsp;</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Field') . "</td>";
        echo "<td>";
        if ($ID > 0) {
            echo "<input type='hidden' name='field' value='" . $this->fields['field'] . "'>";
            $searchOption = $item->getSearchOptionByField('field', $this->fields['field']);
            echo $searchOption['name'];
        } else {
            echo "<span id='span_fields' name='span_fields'>";
            self::dropdownFields($item, $_SESSION['glpilanguage']);
            echo "</span>";
        }
        echo "</td>";
        echo "<td>" . __('Value') . "</td>";
        echo "<td><input type='text' name='value' value=\"" . $this->fields['value'] . "\" size='50'>";
        echo "</td>";
        echo "</tr>\n";
        $this->showFormButtons($options);
        return true;
    }