-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
write new position field to mimic the one used in com_modules
- Loading branch information
1 parent
31b18fe
commit 05da471
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
defined('JPATH_BASE') or die(); | ||
|
||
jimport('joomla.html.html'); | ||
jimport('joomla.form.formfield'); | ||
|
||
class JFormFieldPosition extends JFormField { | ||
protected $type = "position"; | ||
|
||
protected function getInput() { | ||
require_once JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php'; | ||
JHtml::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_modules/helpers/html'); | ||
$language = JFactory::getLanguage(); | ||
$language->load('com_modules', JPATH_ADMINISTRATOR); | ||
|
||
$clientId = 0; | ||
$state = 1; | ||
$selectedPosition = $this->value; | ||
$positions = JHtml::_('modules.positions', $clientId, $state, $selectedPosition); | ||
|
||
|
||
// Add custom position to options | ||
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION'); | ||
|
||
// Build field | ||
$attr = array( | ||
'id' => $this->id, | ||
'list.select' => $this->value, | ||
'list.attr' => 'class="chzn-custom-value input-xlarge" ' | ||
. 'data-custom_group_text="' . $customGroupText . '" ' | ||
. 'data-no_results_text="' . JText::_('COM_MODULES_ADD_CUSTOM_POSITION') . '" ' | ||
. 'data-placeholder="' . JText::_('COM_MODULES_TYPE_OR_SELECT_POSITION') . '" ' | ||
); | ||
|
||
return JHtml::_('select.groupedlist', $positions, $this->name, $attr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters