Contao\Widget::optionChecked PHP Method

optionChecked() public static method

Return a "checked" attribute if the option is checked
public static optionChecked ( string $strOption, mixed $varValues ) : string
$strOption string The option to check
$varValues mixed One or more values to check against
return string The attribute or an empty string
    public static function optionChecked($strOption, $varValues)
    {
        if ($strOption === '') {
            return '';
        }
        return is_array($varValues) ? in_array($strOption, $varValues) : $strOption == $varValues ? ' checked' : '';
    }

Usage Example

Esempio n. 1
0
 /**
  * Return a "checked" attribute if the option is checked
  *
  * @param string $strOption The option to check
  * @param mixed  $varValues One or more values to check against
  *
  * @return string The attribute or an empty string
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use Widget::optionChecked() instead.
  */
 public static function optionChecked($strOption, $varValues)
 {
     trigger_error('Using Controller::optionChecked() has been deprecated and will no longer work in Contao 5.0. Use Widget::optionChecked() instead.', E_USER_DEPRECATED);
     return \Widget::optionChecked($strOption, $varValues);
 }