General developer forum

How to change customize addElement from formslib?

 
 
Picture of Christos Savva
How to change customize addElement from formslib?
 

Hello, I am trying to create a custom form on my Moodle and I am using the following code


$mform->addElement('select', 'type', 'Question', array("Yes"=>"Yes","No"=>"No"));

This creates something like this but the label and options are displayed horizontally (showed below)

Example

<div id="fitem_id_type" class="fitem fitem_fselect ">

<div class="fitemtitle">

<label for="id_type">Question</label></div>

<div class="felement fselect">

<select name="type" id="id_type">

<option value="Yes">Yes</option>

<option value="No">No</option>

</select>

</div>

</div>


I want to either find a way to expand the label to full width or push the options below .


Is there a way to add a style to the fitemtitle div? I want this change to be done only to this page, that's why I don't want to mess with css.


is there a way to overwrite the css in this page only?

 
Average of ratings: -
Davo
Re: How to change customize addElement from formslib?
Group DevelopersGroup Particularly helpful Moodlers

Take a look at the body tag for you form's page.

It should have an element that looks like (or something similar, related to the name of your plugin):

path-mod-mymodname

This should allow you to uniquely specify the page on which you want the CSS styling to have an effect.


 
Average of ratings: -