Back to CheckboxesField class

Method getLayoutData

protected array
getLayoutData
()
Method to get the data to be passed to the layout for rendering.
Returns
  • array
Since
  • 3.5

Method getLayoutData - Source code

/**
 * Method to get the data to be passed to the layout for rendering.
 *
 * @return  array
 *
 * @since   3.5
 */
protected function getLayoutData()
{
    $data = parent::getLayoutData();
    // True if the field has 'value' set. In other words, it has been stored, don't use the default values.
    $hasValue = isset($this->value) && !empty($this->value);
    // If a value has been stored, use it. Otherwise, use the defaults.
    $checkedOptions = $hasValue ? $this->value : $this->checkedOptions;
    $extraData = array('checkedOptions' => \is_array($checkedOptions) ? $checkedOptions : explode(',', (string) $checkedOptions), 'hasValue' => $hasValue, 'options' => $this->getOptions());
    return array_merge($data, $extraData);
}