[ic] should be simple form and [if] condition

Doug Alcorn doug@lathi.net
25 Jan 2001 12:39:27 -0500

I was writing a form to add to the UI and based it off the layout.html
file in UI/pages/admin.  The goal of this form is to provide a text
input populated with the saved value in the database and allow the
user to change the value.  If it is changed, save it in the
database. Here's the very simple version of the working form:

<FORM METHOD=GET ACTION="[process]" name="phoneform">
<input type=hidden name=mv_todo        value=return>
<input type=hidden name=mv_nextpage    value="@@MV_PAGE@@">
[seti saved_model][data table=phones column=model key="[value phone]"][/seti]
[seti entered_model][value model][/seti]
[if type="explicit"][condition]
   $model = $Scratch->{entered_model};
   $saved = $Scratch->{saved_model};
   return 1 if $model eq $saved;
   return 0;
[/condition]<!-- no need to save model -->
[seti saved_model]
[data table=phones column=model key="[value phone]" value="[scratch entered_model]"][/seti]
[set entered_model][/set]
<input type=text size=20 name=model value="[scratch saved_model]">
<input type=submit value="Change">

There is a <select name="phone"> box that is build with values from
the phones table on the same form.  I know that [value model] and
[scratch saved_phone] return what I expect.  I had for quite a while
those values being printed out on the page enclosed in single quotes
(so no extra spaces).

My question is about the overly complicated [if ][/if] block.  I would
have like to have done:

[if value model ne [scratch saved_model]]
  [data ... value="[value model]"]

However, I could not get that to work for anything.  I tried many
variations.  Here's another one that didn't work:

[if type="explicit"][condition]
  $entered = '[value model]';
  $saved = '[data table=phoens column=model key="[value phone]"]';
  return 1 if $entered ne $saved;
  return 0;
[/condition]not equal[else]equal[/if]

In fact, even if I hard coded either $entered or $saved and left the
other one set to '[tag args]' it wouldn't test as expected.  What is
it I'm not understanding?  What's missing here?
 (__) Doug Alcorn (mailto:doug@lathi.net http://www.lathi.net)
 oo / PGP 02B3 1E26 BCF2 9AAF 93F1  61D7 450C B264 3E63 D543
 |_/  If you're a capitalist and you have the best goods and they're
      free, you don't have to proselytize, you just have to wait.