CoreFiles by mySites.guru
checkboxes.php63 lines, 1,212 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
7b779cad33c4944c9008baf077a752d8
sha1
a475810c89ddf190bc530e1cfa01a5219d8a42c1
sha256
225219df9cd29c63ebc65a6425f29bf85b2a1782229f463e126fa660b702f055
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Checkboxes
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Fields Checkboxes Plugin
 *
 * @since  3.7.0
 */
class PlgFieldsCheckboxes extends \Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin
{
	/**
	 * Before prepares the field value.
	 *
	 * @param   string     $context  The context.
	 * @param   \stdclass  $item     The item.
	 * @param   \stdclass  $field    The field.
	 *
	 * @return  void
	 *
	 * @since   3.7.0
	 */
	public function onCustomFieldsBeforePrepareField($context, $item, $field)
	{
		if (!$this->app->isClient('api'))
		{
			return;
		}

		if (!$this->isTypeSupported($field->type))
		{
			return;
		}

		$field->apivalue = [];

		$options = $this->getOptionsFromField($field);

		if (empty($field->value))
		{
			return;
		}

		if (is_array($field->value))
		{
			foreach ($field->value as $key => $value)
			{
				$field->apivalue[$value] = $options[$value];
			}
		}
		else
		{
			$field->apivalue[$field->value] = $options[$field->value];
		}
	}
}

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.