0
我有一個代碼如何在生成的代碼中添加屬性?
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();
此代碼生成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>
我需要屬性添加到按鈕:
onclick="yaCounterXXXXXX.reachGoal('ORDER'); return true;"
它的Joomla狐接觸形式。對不起,自動代碼。我複製並粘貼它。
我只是想同前問一個問題後,添加此
。該頁面沒有加載。但是現在我複製了你的代碼並且工作。我認爲我在某個地方犯了錯誤))謝謝 – fibboo
如果它解決了您的問題,請將其標記爲答案!快樂的編碼 –