How to add HTML to form submit button?

Notice: This thread is very old.
wise
Member | 161
+
0
-

Hi guys,

i want to add some html to submit button.

If i try it with other form elements, it's ok:

<?php
$star = Html::el('span')->addAttributes(array('class' => 'red'))->setText('*');
$form->addText('name', Html::el('')->setText('Jméno')->add($star))
?>

but in submit i get this: https://www.dropbox.com/…13.25.09.png

<?php
$icon = Html::el('i')->addAttributes(array('class' => 'icon-double-angle-right icon-large'));
$form->addSubmit('submit', Html::el('')->setText('ODESLAT')->add($icon));
?>

Thanks in advance.

jiri.pudil
Nette Blogger | 1029
+
0
-

I guess that's correct behavior, since in case of submit button you're setting its “value” attribute, not the markup (label). You can access and modify the markup of the button itself though.

petr.pavel
Member | 535
+
0
-

You could try adding the classes to the submit button itself.

$form->addSubmit('submit', 'ODESLAT')
  ->getControlPrototype()->class('icon-double-angle-right icon-large');
Tomáš Votruba
Moderator | 1114
+
0
-

@wise: I solved this by custom control IconSubmitButton