1

I thought there should be an easy way like:

echo $this->form->getInput('similar_text', array('style' => 'background: red;'));

But it seems to be harder than my except.

I need to generate an output like this:

<input type="text" name="jform_similar_text" style="background: red;" />

How should I do it using Joomla's Standard way?

Environment: Joomla 3.4

Thank you

5

Joomla! dosen't support style attribute on text field or sending it with getInput method.

I expect you know where similar_text field is defined in XML. If you don't then they are usually in /components/COMPONENT_NAME/models/forms for components. For modules, they are in general .xml file.

You should add class attribute to that field.

XML

<field 
    name="similar_text" 
    type="text"
    label="Similar text"
    class="inputbox red-bg" />

Then create .css file and load it on your extension. See here how it's done.

CSS

input.red-bg{
    background: red;
}
1

Create one xml file for example

<field name="jform_similar_text"
            type="text"
            label="sample"
            description="sample"
            size="50"
            class="inputbox" />

then write a default.php file in views

<tr>
    <td>
        <?php echo $this->form->getLabel('jform_similar_text'); ?>
    </td>
    <td>
        <?php echo $this->form->getInput('jform_similar_text'); ?>
    </td>
</tr>
  • Sorry, I couldn't understand. Possible for you to explain more clearly & with a step by step basis? – Mohammad Naji Jul 14 '15 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.