}
+/*
+ Flush hidden fields buffer.
+*/
+function output_hidden()
+{
+ global $hidden_fields;
+
+ echo implode('', $hidden_fields);
+ $hidden_fields = array();
+}
//---------------------------------------------------------------------------------
function end_form($breaks=0)
hidden('_confirmed'); // helper for final form confirmation
hidden('_token', $_SESSION['csrf_token']);
- echo implode('', $hidden_fields)."</form>\n";
+ output_hidden();
+ echo "</form>\n";
$Ajax->activate('_token');
$Ajax->activate('_confirmed');
}
function end_table($breaks=0)
{
echo "</table></center>\n";
+ output_hidden();
if ($breaks)
br($breaks);
}
}
//---------------------------------------------------------------------------------
-$hidden_fields = array(); // store for hiddn fields attached just before form end (for proper html validation)
+//
+// Thanks to hidden fields buffering hidden() helper can be used in arbitrary places and
+// proper html structure is still preserved. Buffered hidden fields are output on the nearest
+// table or form closing tag (see output_hidden()).
+//
+$hidden_fields = array();
function hidden($name, $value=null, $echo=true)
{