Question

is it possible to use in xml structure of a form bootsraps input-prepend class in case of joomla 3? I mean I have the following xml structure

      <field name="subject" type="text"
        label="COM_UNIS_FIELDSET_SUBJECT_TITLE_LABEL"
        description="COM_UNIS_FIELDSET_SUBJECT_TITLE_DESC"
        class="inputbox"
        size="30"
    />

would be possible to use in this case the bootstrap class for input prepender

<div class="input-prepend">
<span class="add-on">my-icon</span>
<input class="span2" id="prependedInput" type="text" placeholder="subject">
</div>
Was it helpful?

Solution

It seems you have to look to: http://docs.joomla.org/Creating_a_custom_form_field_type. You could define a custom field by extending the Jform class:

<?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
        }
}

With the getInput() function you could return any html.

Or try to use jQuery to style your forms (eample):

<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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top