diff --git a/src/administrator/components/com_weblinks/models/forms/weblink.xml b/src/administrator/components/com_weblinks/models/forms/weblink.xml
index f3b6cda..0864345 100644
--- a/src/administrator/components/com_weblinks/models/forms/weblink.xml
+++ b/src/administrator/components/com_weblinks/models/forms/weblink.xml
@@ -17,11 +17,14 @@
description="COM_WEBLINKS_FIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER" />
-
-
-
+
0)
+ {
+ $catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_weblinks');
+ }
+
+ // Save New Category
+ if ($catid == 0 && $this->canCreateCategory())
+ {
+ $table = array();
+ $table['title'] = $data['catid'];
+ $table['parent_id'] = 1;
+ $table['extension'] = 'com_weblinks';
+ $table['language'] = $data['language'];
+ $table['published'] = 1;
+
+ // Create new category and get catid back
+ $data['catid'] = CategoriesHelper::createCategory($table);
+ }
+
// Alter the title for save as copy
if ($app->input->get('task') == 'save2copy')
{
@@ -332,4 +357,37 @@ class WeblinksModelWeblink extends JModelAdmin
return array($name, $alias);
}
+
+ /**
+ * Allows preprocessing of the JForm object.
+ *
+ * @param JForm $form The form object
+ * @param array $data The data to be merged into the form object
+ * @param string $group The plugin group to be executed
+ *
+ * @return void
+ *
+ * @since 3.6.0
+ */
+ protected function preprocessForm(JForm $form, $data, $group = 'content')
+ {
+ if ($this->canCreateCategory())
+ {
+ $form->setFieldAttribute('catid', 'allowAdd', 'true');
+ }
+
+ parent::preprocessForm($form, $data, $group);
+ }
+
+ /**
+ * Is the user allowed to create an on the fly category?
+ *
+ * @return bool
+ *
+ * @since 3.6.0
+ */
+ private function canCreateCategory()
+ {
+ return JFactory::getUser()->authorise('core.create', 'com_weblinks');
+ }
}
diff --git a/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php b/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php
index 4b0c692..a9811ed 100644
--- a/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php
+++ b/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php
@@ -12,7 +12,7 @@ defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
-JHtml::_('formbehavior.chosen', 'select');
+JHtml::_('formbehavior.chosen', 'select', null, array('disable_search_threshold' => 0 ));
// Ignore Image fieldset for the layouts as we render it manually
$this->ignore_fieldsets = array('images');