';
}
/**
* Creates a input tag
*
* @param string $type The type of input it will be
* @param string $name The name (and id) attribute of the input
* @param string $value The value to pre-fill the field with
* @param array $extras Any extra attributes we want to add
*
* @return string $html The completed input tag
*
*/
public static function input($type, $name, $value = '', $extras = []){
$attrs = self::make_attrs(array_merge([
'type' => $type,
'name' => $name,
'id' => $name,
'value' => $value
], $extras));
$html = "";
return $html;
}
/**
*
* Make a string of html attributes out of an array
*
* @param array $extras An array of html attributes and their values
*
* @return string A valid string of html attributes
*
*/
public static function make_attrs($attrs){
$html = '';
foreach($attrs as $key => $val){
$val = str_replace('\'', ''', $val);
$html .= " $key='$val' ";
}
return $html;
}
/**
* Creates a label tag
*
* @param string $for The id attribute of the field this label is for
* @param string $text The text to appear on the label
* @param array $extras Any extra attributes we want to add
*
* @return string $html The completed label tag
*
*/
public static function label($for, $text, $extras = []){
$attrs = self::make_attrs(array_merge([
'for' => $for
], $extras));
$html = "";
return $html;
}
/**
* Creates a textarea tag
*
* @param string $name The name attribute of the textarea
* @param string $value The value to pre-fill the textarea with
* @param array $extras Any extra attributes we want to add
*
* @return string $html The completed textarea tag
*
*/
public static function textarea($name, $value = '', $extras = []){
$attrs = self::make_attrs(array_merge([
'name' => $name,
'id' => $name
], $extras));
$html = "";
return $html;
}
/**
* Creates a set of option tags from an array
*
* @used-by self::select() to get option tags
*
* @param array $values An associative array including the value, and text of each option tag
* @param string $pre_selected The option tag to add the 'select' attribute to
*
* @return string $html The completed option tags
*
*/
public static function options($values, $pre_selected){
$html = '';
foreach($values as $value => $text){
$selected = $pre_selected == $value ? 'selected' : '';
$html .= "";
}
return $html;
}
/**
* Creates a select tag with option tags within it
*
* @uses self::options() to get option tags
*
* @param string $name The name attribute of the