add html to parent form, not to an element
Notice: This thread is very old.
- mikeb
- Member | 33
I'm sure I'm missing something obvious… how can I add a block of html
directly to a form. ie not attached to an input element. for instance a heading
and paragraph of text between two elements. like
$form->addHTML ($el);
(not than addHTML works on the form, of
course).
thanks for your suggestions
- mikeb
- Member | 33
so i made a new class to extend base control:
use Nette\Forms\Form;
use Nette\Utils\Html;
class netteLabel extends Nette\Forms\Controls\BaseControl
{
var $show_label, $html;//mb
public function __construct($label = NULL, $html=null)
{
parent::__construct();
$this->show_label = $label;//mb
$this->html = $html;//mb
}
public function getControl()
{
return Html::el()
->addHtml(Html::el($this->html)->setText($this->show_label));
}
}
and set the element like this:
$html = 'h1';//or whatever
$label = 'grrr';
$form[$el_name] = new \netteLabel($label,$html);
and it gives me html formatted text inline in the form
if there's an easier way please let me know!
Last edited by mikeb (2016-10-27 10:45)