[ic] Table-editor default values

Mike Heins interchange-users@lists.akopia.com
Mon Jul 23 08:01:01 2001


Quoting Bas Bezemer (bas.bezemer@wxs.nl):
> Hi group,
> 
> I've been playing with the table-editor tag that is used in the
> flex_editor page of the administration tool to edit individual database
> entries. Unfortunatelly I can't figure out all the options I suspect it
> the can perform. I want to show an empty form for a new entry in a table
> with a few default values filled in. The default values are passed by
> cgi (field1=value1&field2=value2) and are not the same for every new
> entry. 
> 
> The code of the table-editor shows some references to things that have
> to do with "default", but it is confusing how these can be accessed. It
> shows $opt->{default}, $opt->{defaults} (is this correct
> default/defaults ?), ui_te_default, $default.
> 
> I looked at the "Clone item" option in the Item-editor, but that copies
> all the fields from the original, apart from the key value, by a
> database look up.
> 
> Any clues?
> 

You might look at the pages in lib/UI/pages/admin/wizard -- they 
use most of the options of [table-editor] one time or another.

In this case, it should be automatic if you do

	[update values]
	[table-editor table=foo]

If you want to pre-set only if there is not a current value in that
key in the table (my guess):

	[table-editor
		table=foo
		default.field1=`$CGI->{field1}`
		default.field2=`$CGI->{field1}`
	]

You have to use the Perl notation because the hash-based keys of
the default option don't interpolate for Interchange tags.

You can do the same thing with only incoming variables if you do:

	[table-editor table=foo cgi=1]

Then you format a link like:

	[page href=your_editor
		form="
			field1=foo
			field2=bar
			ui_te_default:field1=your default value 1
			ui_te_default:field2=your default value 2
		"
	]Edit foo[/table]

I may at some point write docs for table-editor, which with its
"wizard" mode is really an application in itself. For now it is
supposed to be one of the undocumented things in the UI, of which
there are many.

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

When the only tool you have is a hammer, all your problems tend to look
like nails.  -- Abraham Maslow