Hello,
when I try this code in the Form Code tab, to generate HTML, the field list under the AutoGeneration code displays ''.$name." in stead of the list of fields:
Is there a way to use this type of HTML generation by PHP functions?
Gr, Jan
when I try this code in the Form Code tab, to generate HTML, the field list under the AutoGeneration code displays ''.$name." in stead of the list of fields:
<?php
$user = JFactory::getUser();
if ( $user->id == 0 ) {
// this is a guest . . .
} else {
function haal_data_op() {
$db = & JFactory::getDBO();
$query = "SELECT * FROM #__chronoforms_Locatie_edit WHERE cf_id=1";
$db->setQuery($query);
$rows = $db->loadAssocList();
foreach ( $rows as $row ) {};
return $row;
}
function cf_heading ($heading) {
echo '<DIV class=form_item >';
echo '<DIV class="form_element cf_heading" >';
echo '<H2 class=cf_text >'.$heading.'</H2></DIV>';
echo '<DIV class=clear > </DIV></DIV>';
}
function cf_textbox ($label, $required, $name) {
$data = haal_data_op();
echo '<DIV class=form_item >';
echo '<DIV class="form_element cf_textbox" >';
echo '<LABEL class=cf_label >'.$label.'</LABEL>';
echo '<INPUT class="cf_inputbox';
if ($required==1) echo ' required" '; else echo '" ';
echo 'id='.$name.' maxLength=150 size=30 name='.$name.' value="'.$data[$name].'"></DIV>';
echo '<DIV class=clear > </DIV></DIV>';
}
function cf_dropdown ($label, $name) {
$data = haal_data_op();
echo '<DIV class=form_item >';
echo '<DIV class="form_element cf_dropdown" >';
echo '<LABEL class=cf_label >'.$label.'</LABEL>';
echo '<SELECT class=cf_inputbox id='.$name.' size=1 name='.$name.' >';
echo '<OPTION value="0">Maak een keuze</OPTION>';
$db = & JFactory::getDBO();
$query = "SELECT * FROM #__chronoforms_keuzes WHERE categorie='$name' group by keuze";
$db->setQuery($query);
$rows = $db->loadAssocList();
foreach ( $rows as $row ) {
echo '<OPTION value="'.$row[cf_id].'" ';
if ($row[cf_id]==$data[$name]) echo 'selected';
echo '>'.$row[keuze].'</OPTION>';
}
echo '</SELECT></DIV>';
echo '<DIV class=clear > </DIV></DIV>';
}
cf_heading("Algemene informatie over de locatie");
cf_textbox("Naam",1,"locatie_naam");
cf_dropdown("Plaatsnaam","locatie_plaatsnaam");
cf_dropdown("Land","locatie_land");
cf_dropdown("Kenmerk","locatie_kenmerk");
cf_dropdown("Publiek","locatie_zichtpubliek");
cf_dropdown("Bereikbaarheid","locatie_bereikbaarheid");
cf_dropdown("Parkeergelegenheid","locatie_parkeergelegenheid");
?>
<DIV class=form_item >
<DIV class="form_element cf_fileupload" ><LABEL class=cf_label >Foto terrein</LABEL><INPUT class=cf_inputbox id=file_0 type=file name=file_0 ><A class=tooltiplink onclick="return false;" ><IMG class=tooltipimg height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv >Foto terrein:: Max 500 kB</DIV></DIV>
<DIV class=clear > </DIV></DIV>
<? cf_textbox ("Coordinaten", 0, "locatie_coordinaten"); ?>
<DIV class=form_item >
<DIV class="form_element cf_button" ><INPUT type=submit value=Opslaan></DIV>
<DIV class=clear > </DIV></DIV>
<? }
?>
Is there a way to use this type of HTML generation by PHP functions?
Gr, Jan
Hi Jan, unfortunately generating fields with PHP will not work! Chronoforms will need to know fields names when you save the form!
Regards
Max
Regards
Max
This topic is locked and no more replies can be posted.