Back to Grid class

Method id

public static mixed
id
(mixed $rowNum, mixed $recId, mixed $checkedOut = false, mixed $name = 'cid', mixed $stub = 'cb', mixed $title = '', mixed $formId = null)
Method to create a checkbox for a grid row.
Parameters
  • int $rowNum The row index
  • int $recId The record id
  • bool $checkedOut True if item is checked out
  • string $name The name of the form element
  • string $stub The name of stub identifier
  • string $title The name of the item
  • string $formId An optional form selector.
Returns
  • mixed String of html with a checkbox if item is not checked out, null if checked out.
Since
  • 1.5
Class: Grid
Project: Joomla

Method id - Source code

/**
 * Method to create a checkbox for a grid row.
 *
 * @param   integer  $rowNum      The row index
 * @param   integer  $recId       The record id
 * @param   boolean  $checkedOut  True if item is checked out
 * @param   string   $name        The name of the form element
 * @param   string   $stub        The name of stub identifier
 * @param   string   $title       The name of the item
 * @param   string   $formId      An optional form selector.
 *
 * @return  mixed    String of html with a checkbox if item is not checked out, null if checked out.
 *
 * @since   1.5
 */
public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid', $stub = 'cb', $title = '', $formId = null)
{
    if ($formId !== null) {
        return $checkedOut ? '' : '<label for="' . $stub . $rowNum . '"><span class="visually-hidden">' . Text::_('JSELECT') . ' ' . htmlspecialchars($title, ENT_COMPAT, 'UTF-8') . '</span></label>' . '<input class="form-check-input" type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId . '" onclick="Joomla.isChecked(this.checked, \'' . $formId . '\');">';
    }
    return $checkedOut ? '' : '<label for="' . $stub . $rowNum . '"><span class="visually-hidden">' . Text::_('JSELECT') . ' ' . htmlspecialchars($title, ENT_COMPAT, 'UTF-8') . '</span></label>' . '<input class="form-check-input" autocomplete="off" type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId . '" onclick="Joomla.isChecked(this.checked);">';
}