I can't create HTML form in a php loop in a function. Here what I did:
foreach ($products as $product) {
$html .= "<tr>
<form method='POST' id='form-".$product->virtuemart_product_id."' class='product js-recalculate' action = '' >";
$html .="<td>".$product->product_s_desc."</td>";
if($showattribute == 1) {
$html .="<td class='product_attribute' id='PerUnitAttr".$product->virtuemart_product_id."'>";
if (!empty($product->customfieldsCart)) {
foreach ($product->customfieldsCart as $field) {
$html .= "<p><b>". $field->custom_title."</b></p>";
$html .= "<p>". $field->display."</p>";
}
}
$html .= "</td>";
}
$html .=
'<td><span class="quantity-box">
<input type="text" class="quantity-input" id="PerUnitQuantity'.$product->virtuemart_product_id.'" name="quantity[]" value="1"/>
</span>
<span class="quantity-controls">
<input type="button" id="PerUnitPlus'.$product->virtuemart_product_id.'" class="quantity-controls quantity-plus" />
<input type="button" id="PerUnitMinus'.$product->virtuemart_product_id.'" class="quantity-controls quantity-minus" />
</span>
<input type="hidden" class="pname" value="'. $product->product_name .'"/>
';
$html .="<td><span style='margin-left: 8px;' id='PerUnitTotal".$product->virtuemart_product_id."'> 0 </span> ".$currency->getSymbol()."</td>
</form></tr>";
}
return $html;
But that form not showing up & inserting closing tag before in where I ended it. It's something like this:
<tr>
<form id="form-72" class="product js-recalculate" action="" method="POST">
</form>
<td></td>
<tr>
<form id="form-6" class="product js-recalculate" action="" method="POST"></form>
<td></td>
In where I did mistake ?
For more specific what I wanted to do the output will be like this:
<table>
loop start
<form action='' id='id='form-".$data."'>
<tr>
<td></td>
</tr>
</form>
loop end
</table>
But output not showing correctly.
$html .= "<tr> <form method='POST' id='form-".$product->virtuemart_product_id."' class='product js-recalculate' action = '' >? You're missing a";.$product?