Open Hubbitus opened 4 years ago
Hi. Thanks for your suggestion but I'm not convinced. This library does not pretend to provide a full template system, just the minimum required to render a form. But for more complex layout, you should implement it in your own templates. For example:
function renderRadio($input) {
$value = $input->getAttribute('value');
return "<li><a href=\"#tab_realty_type_{$value}\">{$input}</a></li>";
}
echo '<ul>';
foreach ($form->filter_realty_type as $input) {
echo renderRadio($input);
}
echo '</ul>';
This is a better (and more performant) solution. Your suggestion is not valid because it is for your specific use case. Other users may want to get the real id
(not the value
), or any other different attribute.
Sure, I can also build form without that library too ;)
There may be an even more flexible solution. What do you think about setTemplate
method which will allow pass lambda for formatting?
That's small enhancment which is not break anything, is not? Could you please add it?
Said I have form:
And I would like access values
residential
,rural
and so on in my template like:In my case for use with jQuery tabs plugin, but I think it would be helpfull in other cases too.
Change seams trivial like do in Input.php:
If you wish I could prepare PR.
P.S. Is it possible to provide the template for all
radio
objects once atradioGroup
level?