Answer the question
In order to leave comments, you need to log in
Table template?
The meaning is this: there are document templates in which fields need to be replaced. Single fields are replaced with just "Hi {username}", for example. But the question arose - what to do with tabular data? You cannot replace a table with a single field. In short, you need to be able to change the table fields in the template (and their order, of course), and preferably the design styles. In addition, there should not be PHP code inside the template, that is, the template should be easily edited by Aunt Zina from the accounting department :)
I don’t want to reinvent my wheel, but I didn’t find anything suitable off the top of my head.
Answer the question
In order to leave comments, you need to log in
Something seems to me that there are no standard solutions, at least I don’t remember.
If I were you, I would take some smarty or twig and write a plugin for tables.
Something like
[table name="test", fields=['id','name','surname'] ]
Lately I've been using megafon's Histone. It is very convenient, since full compatibility of PHP-JS templates.
Привет, {{username}}!
<table>
{{for item in items}}
<tr><td>{{item.name}}</td><td>{{item.value}}</td></tr>
</table>
As you know, PHP allows you to send multilevel arrays in POST requests. Actually, it is quite possible to generate such fields-arrays for the table as well. The only viable option I see.
Like this:
<table>
<tr>
<td><input type="text" name="table[0][0]" /></td>
<td><input type="text" name="table[0][1]" /></td>
</tr>
<tr>
<td><input type="text" name="table[1][0]" /></td>
<td><input type="text" name="table[1][1]" /></td>
</tr>
<?php
var_dump($_POST['table']);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question