View Single Post
  #9  
Old 7th May 2013, 00:05
dclardy dclardy is offline
Senior Member
 
Join Date: Sep 2009
Location: Dallas, TX
Posts: 347
Thanks: 10
Thanked 47 Times in 28 Posts
Default

After even more finding, I can get it to save to the the database table now. The only issue is that it always inserts a new record instead of updating the data? How can I change that functionality? I need it to update here. Is there a parameter than I need to send that I am not.

tpl_ispc-clean_edit.php

Code:
<?php

/******************************************
* Begin Form configuration
******************************************/

$tform_def_file = "form/tpl_ispc-clean.tform.php";

/******************************************
* End Form configuration
******************************************/

require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');

//* Check permissions for module
$app->auth->check_module_permissions('admin');

// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');

class page_action extends tform_actions {

}

$page = new page_action;
$page->onLoad();

?>
tpl_ispc-clean.tform.php
Code:
<?php

/*
	Form Definition

	Tabellendefinition

	Datentypen:
	- INTEGER (Wandelt Ausdrücke in Int um)
	- DOUBLE
	- CURRENCY (Formatiert Zahlen nach Währungsnotation)
	- VARCHAR (kein weiterer Format Check)
	- TEXT (kein weiterer Format Check)
	- DATE (Datumsformat, Timestamp Umwandlung)

	Formtype:
	- TEXT (normales Textfeld)
	- TEXTAREA (normales Textfeld)
	- PASSWORD (Feldinhalt wird nicht angezeigt)
	- SELECT (Gibt Werte als option Feld aus)
	- RADIO
	- CHECKBOX
	- FILE

	VALUE:
	- Wert oder Array

	Hinweis:
	Das ID-Feld ist nicht bei den Table Values einzufügen.


*/

$form["title"] 		= "ISPC-Clean Theme Settings";
$form["description"]= "Basic Settings for the ISPC-Clean Theme";
$form["name"] 		= "tpl_ispc-clean_settings";
$form["action"]		= "tpl_ispc-clean_edit.php";
$form["db_table"]	= "tpl_ispc_clean";
$form["db_table_idx"]	= "theme_settings_id";
$form["db_history"]	= "yes";
$form["tab_default"]= "basic";
$form["list_default"]	= "server_list.php";
$form["auth"]		= 'yes';

$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete

$theme_sql = $app->db->queryOneRecord("SELECT * FROM `tpl_ispc_clean` where theme_settings_id = 1 ");

$form["tabs"]['basic'] = array (
	'title' 	=> "Basic Settings",
	'width' 	=> 80,
	'template' 	=> "templates/tpl_ispc-clean_edit.htm",
	'fields' 	=> array (
	##################################
	# Beginn Datenbankfelder
	##################################
		'logo_url' => array (
			'datatype'	=> 'VARCHAR',
			'formtype'	=> 'TEXT',
			'default'	=> $theme_sql['logo_url'],
			'value'		=> '',
			'separator'	=> '',
			'width'		=> '40',
			'maxlength'	=> '255'
		),
        'sidebar_state' => array (
			'datatype'	=> 'INTEGER',
			'formtype'	=> 'SELECT',
			'default'	=> $theme_sql['sidebar_state'],
			'value'		=> array(0 => 'Off', 1 => 'On'),
		),
	##################################
	# ENDE Datenbankfelder
	##################################
	)
);

?>
tpl_ispc-clean_edit.htm
Code:
<h2><tmpl_var name="tpl_ispc-clean_head_txt"></h2>
<p><tmpl_var name="tpl_ispc-clean_desc_txt"></p>

<div class="panel panel_system_config">
    
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Basic Settings</legend>
            <div class="ctrlHolder">
                <label for="logo_url"><tmpl_var name='logo_url_txt'></label>
                <input name="logo_url" id="logo_url" value="{tmpl_var name='logo_url'}" size="50" maxlength="255" type="text" class="textInput" />&nbsp; Size:&nbsp;152x46px
            </div>
            <div class="ctrlHolder">
                <label for="sidebar_state">{tmpl_var name='sidebar_state_txt'}</label>
                <select class="selectInput" id="sidebar_state" name="sidebar_state">
                    {tmpl_var name='sidebar_state'}
                </select>
            </div>
        </fieldset>
        {tmpl_var name='sidebar_state'}
        <input type="hidden" name="id" value="{tmpl_var name='id'}">

        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','admin/tpl_ispc-clean_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onclick="loadContent('admin/server_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
Please any help would be appreciated.
Reply With Quote