CoreFiles by mySites.guru
checkboxes.php63 lines, 1,212 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
3255b213ceb07755c67acdd23ea26ba1
sha1
c6bc34a54d75282b6c4c8ebe1fe84ae8d9cbd881
sha256
3635dddd7f56a68b4689b794871329f0f1f7ecb15453fa3cacf5be21a4038350
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Checkboxes
 *
 * @copyright   Copyright (C) 2005 - 2019 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];
		}
	}
}

No other release has this exact content. See every version of this file.