Categories > TinyButStrong general >

Displaying Block Data in an HTML Form

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Keith Silva
Date: 2006-12-14
Time: 19:26

Displaying Block Data in an HTML Form

I want to pull data from my database and place it in a form for editing by a user. All works well except for a couple of select drop-down menu text boxes in my form. I can't seem to get the block field to display in the control on the form.

I've looked through the manual and examples and tried several commands without success. I think my circumstances are different from the examples because I'm using a TBS block rather than fields, and I'm pulling data from the database rather than inserting it into the database. I've included my code below.

I'd appreciate any advice regarding the proper TBS syntax or commands.

Thanks, Keith Silva

HTML Side:
<form method="post" action="person_save.php" target="_self" name="Person">
      <div class="prefix">Prefix<br>
        <select name="prefix" "size="1" class="">
          <option selected value="[person.prefix;block=form;magnet=option;mtype=m+m]"></option>
          <option value="Mr.">Mr.</option>
          <option value="Ms.">Ms.</option>
          <option value="Dr.">Dr.</option>
          <option value="Honorable">Honorable</option>
          <option value="Senator">Senator</option>
          <option value="To:">To:</option>
        </select></div>
<?php
PHP Side:
include_once('../sys/tbs_class_php5.php');
include_once('../sys/tbsdb_pdo.php');
include_once('../sys/tbs_plugin_html.php');

$db = new PDO('sqlite:../files/db_mgmt');

//$person_id = $_GET['id'];

$TBS = new clsTinyButStrong;

$TBS->LoadTemplate('../app/tmpl_person.html');
$TBS->MergeBlock('person',$db,"SELECT * FROM tbl_person WHERE person_id =='8'");
$TBS->Show();

?>
By: Keith Silva
Date: 2006-12-15
Time: 00:33

Re: Displaying Block Data in an HTML Form

This seems to work:
<option value="[person.prefix;block=form;magnet=option]">[person.prefix;ope=html;select]</option>

I don't know why, yet. Any other ideas?

Thanks, Keith
By: sheepy
Date: 2006-12-15
Time: 04:46

Re: Displaying Block Data in an HTML Form

First you've to be certain (and explain clearly) what you want to accomplish.

When you want to generate the list of select options, you use block.
When you want to select a select option, you use ope-html;select in the field you want to be picked, as example shows and as your second post shows.

Block is used to *repeativelly* output a 'block' of a series of data; the data may be a list of select options, a column of form, or a full table of data.  In each block (single option, single form, single data cell) you have normal fields.
By: Keith Silva
Date: 2006-12-16
Time: 03:44

Re: Displaying Block Data in an HTML Form

Thank you for your reply. You are right, I am confused about when to use a block and when to use a field.

I don't want to generate the list of select options, just display the option value that is already in the database for the corresponding field in one row of a table. The option value from the field in the database will always be one of the select options hand-coded in the form.

I think the lesson here is that I should be using the method MergeField() and fields in my HTML template rather than the MergeBlock() method that I'm currently using. I'll re-read the manual with this in mind.

Thanks for your help and guidance.

Keith S.