Skip to content

Commit

Permalink
menu_modal: Displaying the correct placeholder from the option (#16459)
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 authored and rdeutz committed Jun 6, 2017
1 parent f32f3c9 commit c3f9ac6
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions administrator/components/com_menus/models/fields/modal/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ class JFormFieldModal_Menu extends JFormField
* @since 3.7.0
*/
protected $type = 'Modal_Menu';

/**
* Determinate, if the select button is shown
*
* @var boolean
* @since 3.7.0
*/
protected $allowSelect = true;

/**
* Determinate, if the clear button is shown
*
* @var boolean
* @since 3.7.0
*/
protected $allowClear = true;

/**
* Determinate, if the create button is shown
*
* @var boolean
* @since 3.7.0
*/
protected $allowNew = false;

/**
* Determinate, if the edit button is shown
*
Expand Down Expand Up @@ -218,7 +218,20 @@ function jSelectMenu_" . $this->id . "(id, title, object) {
}
}

$title = empty($title) ? JText::_('COM_MENUS_SELECT_A_MENUITEM') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// Placeholder if option is present or not
if (empty($title))
{
if ($this->element->option && (string) $this->element->option['value'] == '')
{
$title_holder = JText::_($this->element->option, true);
}
else
{
$title_holder = JText::_('COM_MENUS_SELECT_A_MENUITEM', true);
}
}

$title = empty($title) ? $title_holder : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');

// The current menu item display field.
$html = '<span class="input-append">';
Expand Down Expand Up @@ -359,8 +372,18 @@ function jSelectMenu_" . $this->id . "(id, title, object) {
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';

// Placeholder if option is present or not when clearing field
if ($this->element->option && (string) $this->element->option['value'] == '')
{
$title_holder = JText::_($this->element->option, true);
}
else
{
$title_holder = JText::_('COM_MENUS_SELECT_A_MENUITEM', true);
}

$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
. '" data-text="' . htmlspecialchars(JText::_('COM_MENUS_SELECT_A_MENUITEM', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';
. '" data-text="' . htmlspecialchars($title_holder, ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';

return $html;
}
Expand Down

0 comments on commit c3f9ac6

Please sign in to comment.