看来您必须查看:http ://docs.joomla.org/Creating_a_custom_form_field_type 。您可以通过扩展 Jform 类来定义自定义字段:
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
jimport('joomla.form.formfield');
// The class name must always be the same as the filename (in camel case)
class JFormField<FieldName> extends JFormField {
//The field class must know its own type through the variable $type.
protected $type = '<FieldName>';
public function getLabel() {
// code that returns HTML that will be shown as the label
}
public function getInput() {
// code that returns HTML that will be shown as the form field
}
}
使用 getInput() 函数,您可以返回任何 html。
或者尝试使用 jQuery 来设置表单样式(示例):
<body>
<div class="container">
<input type="text" name="subject">
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<script>
$('input[name$="subject"]').wrap('<div class="input-prepend" />');
$('.input-prepend').prepend('<span class="add-on">my-icon</span>');
</script>
</body>