}
protected function get_name_field($id) {
- return '<input type="text" id="' . $id . '" name="' . $id . '" maxlength="254" value="' . s($this->role->name) . '" />';
+ return '<input type="text" class="form-control" id="' . $id . '" name="' . $id . '" size="30"
+ value="' . s($this->role->name) . '" />';
}
protected function get_shortname_field($id) {
- return '<input type="text" id="' . $id . '" name="' . $id . '" maxlength="254" value="' . s($this->role->shortname) . '" />';
+ return '<input type="text" class="form-control" id="' . $id . '" name="' . $id . '" size="30"
+ value="' . s($this->role->shortname) . '" />';
}
protected function get_description_field($id) {
- return '<textarea class="form-textarea" id="'. s($id) .'" name="description" rows="10" cols="50">' .
+ return '<textarea class="form-textarea form-control" id="'. s($id) .'" name="description" rows="10" cols="50">' .
htmlspecialchars($this->role->description) .
'</textarea>';
}
foreach (get_role_archetypes() as $type) {
$options[$type] = get_string('archetype'.$type, 'role');
}
- return html_writer::select($options, 'archetype', $this->role->archetype, false);
+ return html_writer::select($options, 'archetype', $this->role->archetype, false,
+ array('class' => 'custom-select'));
}
protected function get_assignable_levels_control() {
if ($this->roleid == 0) {
$options[-1] = get_string('thisnewrole', 'core_role');
}
- return html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple'=>'multiple', 'size'=>10));
+ return html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple' => 'multiple',
+ 'size' => 10, 'class' => 'form-control'));
}
/**
return '';
}
- protected function print_field($name, $caption, $field) {
+ /**
+ * Print labels, fields and help icon on role administration page.
+ *
+ * @param string $name The field name.
+ * @param string $caption The field caption.
+ * @param string $field The field type.
+ * @param null|string $helpicon The help icon content.
+ */
+ protected function print_field($name, $caption, $field, $helpicon = null) {
global $OUTPUT;
// Attempt to generate HTML like formslib.
- echo '<div class="fitem">';
- echo '<div class="fitemtitle">';
+ echo '<div class="fitem row form-group">';
+ echo '<div class="fitemtitle col-md-3">';
if ($name) {
echo '<label for="' . $name . '">';
}
if ($name) {
echo "</label>\n";
}
+ if ($helpicon) {
+ echo '<span class="pull-xs-right text-nowrap">'.$helpicon.'</span>';
+ }
echo '</div>';
if (isset($this->errors[$name])) {
$extraclass = ' error';
} else {
$extraclass = '';
}
- echo '<div class="felement' . $extraclass . '">';
+ echo '<div class="felement col-md-9 form-inline' . $extraclass . '">';
echo $field;
if (isset($this->errors[$name])) {
echo $OUTPUT->error_text($this->errors[$name]);
protected function print_show_hide_advanced_button() {
echo '<p class="definenotice">' . get_string('highlightedcellsshowdefault', 'core_role') . ' </p>';
echo '<div class="advancedbutton">';
- echo '<input type="submit" name="toggleadvanced" value="' . get_string('hideadvanced', 'form') . '" />';
+ echo '<input type="submit" class="btn btn-secondary" name="toggleadvanced" value="' .
+ get_string('hideadvanced', 'form') . '" />';
echo '</div>';
}
global $OUTPUT;
// Extra fields at the top of the page.
echo '<div class="topfields clearfix">';
- $this->print_field('shortname', get_string('roleshortname', 'core_role').' '.$OUTPUT->help_icon('roleshortname', 'core_role'), $this->get_shortname_field('shortname'));
- $this->print_field('name', get_string('customrolename', 'core_role').' '.$OUTPUT->help_icon('customrolename', 'core_role'), $this->get_name_field('name'));
- $this->print_field('edit-description', get_string('customroledescription', 'core_role').' '.$OUTPUT->help_icon('customroledescription', 'core_role'),
- $this->get_description_field('description'));
- $this->print_field('menuarchetype', get_string('archetype', 'core_role').' '.$OUTPUT->help_icon('archetype', 'core_role'), $this->get_archetype_field('archetype'));
+ $this->print_field('shortname', get_string('roleshortname', 'core_role'),
+ $this->get_shortname_field('shortname'), $OUTPUT->help_icon('roleshortname', 'core_role'));
+ $this->print_field('name', get_string('customrolename', 'core_role'), $this->get_name_field('name'),
+ $OUTPUT->help_icon('customrolename', 'core_role'));
+ $this->print_field('edit-description', get_string('customroledescription', 'core_role'),
+ $this->get_description_field('description'), $OUTPUT->help_icon('customroledescription', 'core_role'));
+ $this->print_field('menuarchetype', get_string('archetype', 'core_role'), $this->get_archetype_field('archetype'),
+ $OUTPUT->help_icon('archetype', 'core_role'));
$this->print_field('', get_string('maybeassignedin', 'core_role'), $this->get_assignable_levels_control());
$this->print_field('menuallowassign', get_string('allowassign', 'core_role'), $this->get_allow_role_control('assign'));
$this->print_field('menuallowoverride', get_string('allowoverride', 'core_role'), $this->get_allow_role_control('override'));
this.table = Y.one('#'+this.tableid);
// Create a div to hold the search UI.
- this.div = Y.Node.create('<div class="capabilitysearchui"></div>').setStyles({
+ this.div = Y.Node.create('<div class="capabilitysearchui form-inline"></div>').setStyles({
width : this.table.get('offsetWidth'),
marginLeft : 'auto',
marginRight : 'auto'
});
// Create the capability search input.
- this.input = Y.Node.create('<input type="text" id="'+this.table.get('id')+'capabilitysearch" value="'+Y.Escape.html(filtervalue)+'" />');
+ this.input = Y.Node.create('<input class="form-control m-x-1" type="text"' +
+ ' id="'+this.table.get('id')+'capabilitysearch" value="'+Y.Escape.html(filtervalue)+'" />');
// Create a label for the search input.
this.label = Y.Node.create('<label for="'+this.input.get('id')+'">'+M.util.get_string('filter', 'moodle')+' </label>');
// Create a clear button to clear the input.
- this.button = Y.Node.create('<input type="button" value="'+M.util.get_string('clear', 'moodle')+'" />').set('disabled', filtervalue=='');
+ this.button = Y.Node.create('<input type="button" class="btn btn-primary"' +
+ ' value="'+M.util.get_string('clear', 'moodle')+'" />').set('disabled', filtervalue=='');
// Tie it all together
this.div.append(this.label).append(this.input).append(this.button);