是否可以在joomla 3的情况下使用表单bootsraps input-prepend类的xml结构?我的意思是我有以下xml结构
<field name="subject" type="text"
label="COM_UNIS_FIELDSET_SUBJECT_TITLE_LABEL"
description="COM_UNIS_FIELDSET_SUBJECT_TITLE_DESC"
class="inputbox"
size="30"
/>
在这种情况下,可以用于输入预编程器的引导类
<div class="input-prepend">
<span class="add-on">my-icon</span>
<input class="span2" id="prependedInput" type="text" placeholder="subject">
</div>
答案 0 :(得分:0)
您似乎必须关注: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>