mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-19756 Migrated print_textfield, choose_from_radio and print_checkbox
This commit is contained in:
parent
49c8c8d27e
commit
6a5c71b95c
3 changed files with 131 additions and 47 deletions
|
@ -621,50 +621,6 @@ function close_window($delay = 0, $reloadopener = false) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display an standard html text field with an optional label
|
||||
*
|
||||
* @param string $name The name of the text field
|
||||
* @param string $value The value of the text field
|
||||
* @param string $alt The info to be inserted in the alt tag
|
||||
* @param int $size Sets the size attribute of the field. Defaults to 50
|
||||
* @param int $maxlength Sets the maxlength attribute of the field. Not set by default
|
||||
* @param bool $return Whether this function should return a string or output
|
||||
* it (defaults to false)
|
||||
* @return string|void If $return=true returns string, else echo's and returns void
|
||||
*/
|
||||
function print_textfield ($name, $value, $alt = '',$size=50,$maxlength=0, $return=false) {
|
||||
|
||||
static $idcounter = 0;
|
||||
|
||||
if (empty($name)) {
|
||||
$name = 'unnamed';
|
||||
}
|
||||
|
||||
if (empty($alt)) {
|
||||
$alt = 'textfield';
|
||||
}
|
||||
|
||||
if (!empty($maxlength)) {
|
||||
$maxlength = ' maxlength="'.$maxlength.'" ';
|
||||
}
|
||||
|
||||
$htmlid = 'auto-tf'.sprintf('%04d', ++$idcounter);
|
||||
$output = '<span class="textfield '.$name."\">";
|
||||
$output .= '<input name="'.$name.'" id="'.$htmlid.'" type="text" value="'.$value.'" size="'.$size.'" '.$maxlength.' alt="'.$alt.'" />';
|
||||
|
||||
$output .= '</span>'."\n";
|
||||
|
||||
if (empty($return)) {
|
||||
echo $output;
|
||||
} else {
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Validates an email to make sure it makes sense.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue