I need a solution for CMS. I would like to edit and create FORMS easily, especially list of settings. Which is better and why?
XML or HTML
Forms occur in View layer - in presentation file. To simplify editing forms and to improve readability, webmasters use additional tags and attributes, e.g. <checkbox>, <radio>, arrayname... The compiler of templates changes XML code into (X)HTML with conditional expressions in PHP and variables (until the template class doesn't compile templates but parse them).
PHP
Form fields and their properties are defined in PHP logic code. Form class generates the HTML form. However, the class needs HTML code of each <form> element - perhaps from template
Examples: http://code.bulix.org/so4zlh-66117
Example of unclear code:
<input type="checkbox" name="name"<!-- IF name --> checked="checked"<!-- END --> />
A lot of such constructions make the code unclear. Similar in pure PHP:
<input type="checkbox" name="name" <?= $name ? 'checked="checked"' : '' ?> />
So I'm looking for a good solution for making <form>s. There are 2 or more methods - XML-based or PHP-based. Which is better and why?
XML-based - example of checkbox:
<checkbox name="name" />
PHP-based:
$form = new Form('...');
$form -> set( /*fields, etc. */);
$template -> set('form', $form);