fibboo fibboo - 5 months ago 13
HTML Question

How to add attribute in generated code?

I have a code

FoxHtmlElem::create('div')
->attr('id', $current->getBoxId())
->classes("fox-item fox-item-submit fox-item-submit-{$current->get('alignment')} control-group")
->classes($current->get('classes'))
->append(FoxFormRender::render('label_collapsed'))
->append(FoxHtmlElem::create('div')
->classes('controls')
->attr('style', "{$current->getStyleWidth()}{$current->getStyleHeight()}")
->append(FoxHtmlElem::create('button')
->classes('btn btn-success submit-button')
->tooltip($current->get('submit.tooltip'))
->attr('type', 'submit')
->append(FoxHtmlElem::create('span')
->append(FoxHtmlElem::create('span')
->classes($current->getIconClass('submit'))
->attr('style', $current->getIconStyle('submit'))
->text($current->get('submit.label')))))
->conditional($current->get('reset.enable'), function () use($current)
{
return FoxHtmlElem::create('button')
->classes('btn btn-danger reset-button')
->tooltip($current->get('reset.tooltip'))
->attr('type', 'reset')
->append(FoxHtmlElem::create('span')
->append(FoxHtmlElem::create('span')
->classes($current->getIconClass('reset'))
->attr('style', $current->getIconStyle('reset'))
->text($current->get('reset.label'))));
}))->show();


This code generates html

<div id="fox-m138-submit-box" class="fox-item fox-item-submit fox-item-submit-fields control-group">
<span class="control-label collapsed"></span>
<div class="controls">
<button type="submit" class="btn btn-success submit-button">
<span>
<span>Отправить</span>
</span>
</button>
</div>




I need to add attribute to the button:

onclick="yaCounterXXXXXX.reachGoal('ORDER'); return true;"


It is joomla fox contact form. Sorry for automated code. I copied and pasted it as it is.

Answer

A wild guess, add this

->attr('onclick', 'yaCounterXXXXXX.reachGoal("ORDER"); return true;')

after the below code

->attr('type', 'reset')