diff --git a/main/inc/lib/extra_field.lib.php b/main/inc/lib/extra_field.lib.php index 24c81fb238..487d671e97 100755 --- a/main/inc/lib/extra_field.lib.php +++ b/main/inc/lib/extra_field.lib.php @@ -60,6 +60,7 @@ class ExtraField extends Model const FIELD_TYPE_FILE_IMAGE = 16; const FIELD_TYPE_FLOAT = 17; const FIELD_TYPE_FILE = 18; + const FIELD_TYPE_VIDEO_URL = 19; public $type = 'user'; public $pageName; @@ -333,6 +334,7 @@ class ExtraField extends Model $types[self::FIELD_TYPE_FILE_IMAGE] = get_lang('FieldTypeFileImage'); $types[self::FIELD_TYPE_FLOAT] = get_lang('FieldTypeFloat'); $types[self::FIELD_TYPE_FILE] = get_lang('FieldTypeFile'); + $types[self::FIELD_TYPE_VIDEO_URL] = get_lang('FieldTypeVideoUrl'); switch ($handler) { case 'course': @@ -1437,6 +1439,14 @@ EOF; } } break; + case ExtraField::FIELD_TYPE_VIDEO_URL: + $form->addUrl( + "extra_{$field_details['variable']}", + $field_details['display_text'], + false, + ['placeholder' => 'https://'] + ); + break; } } } diff --git a/main/inc/lib/formvalidator/Element/Url.php b/main/inc/lib/formvalidator/Element/Url.php new file mode 100644 index 0000000000..e40efc5f97 --- /dev/null +++ b/main/inc/lib/formvalidator/Element/Url.php @@ -0,0 +1,31 @@ +setType('url'); + } + +} diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php index c4acfc9bcc..77d68f61f1 100755 --- a/main/inc/lib/formvalidator/FormValidator.class.php +++ b/main/inc/lib/formvalidator/FormValidator.class.php @@ -973,6 +973,25 @@ EOT; isset($GLOBALS['_HTML_QuickForm_default_renderer']) ? $GLOBALS['_HTML_QuickForm_default_renderer'] : null; } + + /** + * Adds a input of type url to the form. + * @param type $name The label for the form-element + * @param type $label The element name + * @param type $required Optional. Is the form-element required (default=true) + * @param type $attributes Optional. List of attributes for the form-element + */ + public function addUrl($name, $label, $required = true, $attributes = array()) + { + $this->addElement('url', $name, $label, $attributes); + $this->applyFilter($name, 'trim'); + $this->addRule($name, get_lang('InsertAValidUrl'), 'url'); + + if ($required) { + $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); + } + } + } /**