
Gena
Posts: 591
|
| Posted: 02/27/2008, 6:45 AM |
|
I have a standard Record form. Now I need to put some extra Text box, Label etc controls on this form but runtime. Of course I need to get back information from that fields (i.e. text box) on Record submit. How I do this?
The idea is to create a Label and in Event Before Show put generated HTML code like <INPUT value="" name="unit"> so it gives me what I want (I hope, not yet tested). But the problem is how to get Values on submit?
Or is there some standard CCS way?
tia for any suggestions
_________________
Gena |
 |
 |
magus
Posts: 98
|
| Posted: 03/01/2008, 10:19 PM |
|
Hello Gena,
I doubt that one can create a fully CCS coded controls at runtime but may be wrong.
What I did with one project that needed to dynamically generate forms according to configuration details in a database table was to use an editable grid with a selection of controls in each row.
Each control specification from the database included a type. For each row I hid all the controls but the one conforming to the required type. A hidden field was written to each row to indicate which control type to process for each row when the form is submitted.
In the AfterExecuteUpdate event the row hidden type value is tested and the name of the field/control to process is established. Any validation or testing can be done at that time. Or one could perhaps assemble an array of key value pairs to be processed in the After Submit event.
Hiding controls on a per row basis is not pretty but it seems to work.
Another alternative would be to continue with what you have done, but to include a hidden variable containing comma delimited names of the fields you have been written into the form. Call that variable first and explode it to determine which submitted fields have to be processed.Loop through processing the form using CCGetParameter['parameter_name'] and the processing functions found in Common.php.
Regards,
Don A
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 03/02/2008, 3:58 AM |
|
Gena,
Just gave your example a try.
Created a Label 'lVariable' and set content to HTML.
In BeforeShow I added exactly what you posted.
As expected a nice input textbox replaced my lVariable.
Adding any needed HTML could cater for dynamic build up of prompts etc.
Just out of curiosity I added code to the onvalidate of the lVariable.
echo 'entered value :' . CCGetFromPost("unit","");
and it nicely picked up on the entered value.
Which means in basics it is doable.
Based on the fact that CCGetFromPost() will pick up on all Posted variables.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
Gena
Posts: 591
|
| Posted: 03/02/2008, 3:30 PM |
|
Don and Walter,
thank you both for the ideas. I just tried this way:
I have created a standard Record form, added Custom Template Blocks like
<table>
<tr>
<td>Textbox</td>
</tr>
<!-- BEGIN MyTable -->
<tr>
<td> <input type="text" id="Text1" name="{FName}" value="{FVal}"> </td>
</tr>
<!-- END MyTable -->
</table>
then added code like
global $Tpl;
$Tpl->SetVar("FName", "mytext_1" );
$Tpl->Parse("MyTable",True);
$Tpl->SetVar("FName", "mytext_2" );
$Tpl->Parse("MyTable",True);
$Tpl->SetVar("FName", "mytext_3" );
$Tpl->Parse("MyTable",True);
and on Record submit I can get my textbox using code like this:
$mytext1 = CCGetFromPost("mytext_1","");
etc
so in general I checked that it can be done...
_________________
Gena |
 |
 |
|

|
|
|
|