Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modal_menu: Displaying the correct placeholder from the option #16459

Merged
merged 1 commit into from
Jun 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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