0

在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>
4

1 回答 1

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>
于 2013-06-18T22:06:54.760 回答