1

Is there a way to manipulate the resulting HTML that jForm generates?

$this->form->renderField('myfield');

Apparent Joomla Default Form HTML

<div class="control-group">
    <div class="control-label">
        <label id="jform_myfield-lbl" for="jform_myfield" data-placement="bottom">My Field</label>
    </div>
    <div class="controls">
        <input name="jform[myfield]" id="jform_myfield" value="My Value" class="input-sm" placeholder="Enter a value" aria-invalid="false" type="text">
    </div>
</div>

Preferred HTML

<div class="form-group">
    <label for="myfield" class="col-sm-2 control-label">My Field</label>
    <div class="col-sm-10">
        <input class="form-control valid" id="myfield" name="myfield" value="My Value" placeholder="Enter a value" required="" type="text">
    </div>
</div>

1 Answer 1

1

The HTML markup derives from the following file:

layouts/joomla/form/renderfield.php

As this is a layout, you can simply create an override for it. Assuming you're working with a components, copy the file above and paste it in the following directory:

components/com_EXAMPLE/layouts/joomla/form/renderfield.php

You can then make your changes to this file.

Hope this helps

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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