Categories > TinyButStrong general >

More on conditional formatting

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: magicktrickpony
Date: 2004-06-14
Time: 16:02

More on conditional formatting

Dear all,

As a matter of fact I am trying to write a generic all-purpose front-end for database input by generating forms out of table column namespace queries.

Using HTML Forms I want to declare primary key fields as read-only for example, is there any way to control HTML output, so i can pass form options to MergeBlock directly (by using events perhaps?), or do I have to call MergeBlock several times, once for read-only fields, and a second time for the rest, which would take a little time longer..

Thanks for your input.

--The Pony.
By: Skrol29
Date: 2004-06-15
Time: 00:26

Re: More on conditional formatting

Hi,

There is several ways, depending to how you want to display the distinction.
If it's with an image, you can use friend option, if it's only a keyword, you can use if/then/else. If it's more complicated, you can use event functions.
By: magictrickpony
Date: 2004-06-15
Time: 10:03

Re: More on conditional formatting

Well, unfortunately I still need a little more advice..

I'm outputting the keys of a field as blk1.key and the field values as blk1.val for all columns of a table. Now I want to declare special field keys, such as the primary key as "readonly" by using the event functions. I thought by using a special variable called "htmlopt" i can set this to whatever i want, i.e. "readonly" by using the onsection function.

HTML:

<input name="[blk1.key;block=tr;onsection=event_handler1]"
[blk1.htmlopt;htmlconv=no]
type="text" value="[blk1.val;block=tr]">

PHP:
function event_handler1($BlockName,&$CurrRec,&$DetailSrc,$RecNum){
        if ($CurrRec['key'] = 'idx') $CurrRec['htmlopt'] = 'readonly';       
        }

Unfortunately, it isn't as easy like that. :-/

Thanks in advance.
By: magictrickpony
Date: 2004-06-15
Time: 11:07

Re: More on conditional formatting

Ok news as it happens..

I found a solution to my problem - although i think it's more of a kludge - maybe someone can comment on this :-)

I'm using the onformat event to "format" HTML output, I'd have rather done it with an additional variable like "htmlopt" but hey..

HTML:
<input name=[blk1.key;onformat=f_evt_hdl_2;htmlconv=no] type="text" value="[blk1.val]">

PHP:
function f_evt_hdl_2($BlockName,&$CurrRec){
        if ($CurrRec == 'idx') $CurrRec =  $CurrRec.' readonly';
         }
/* "idx" is our primary key here..

Cheers.
By: Skrol29
Date: 2004-06-16
Time: 14:28

Re: More on conditional formatting

Hi,

I would be suprised if this solution with f_evt_hdl_2() work.
In the previous one (event_handler1()) there is a mistake, it should be
  if ($CurrRec['key'] == 'idx')
instead of
  if ($CurrRec['key'] = 'idx')

And you also have to define htmlopt when it is not a primary key.
Exemple:
function event_handler1($BlockName,&$CurrRec,&$DetailSrc,$RecNum){
  if ($CurrRec['key']=='idx') {
    $CurrRec['htmlopt'] = 'readonly';
  } else {
    $CurrRec['htmlopt'] = '';
  }
}