Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Drupal\Core\Field\Plugin\Field\FieldWidget; use Drupal\Core\Field\FieldI..
Decoded Output download
<?php
namespace Drupal\Core\Field\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Plugin implementation of the 'boolean_checkbox' widget.
*
* @FieldWidget(
* id = "boolean_checkbox",
* label = @Translation("Single on/off checkbox"),
* field_types = {
* "boolean"
* },
* multiple_values = TRUE
* )
*/
class BooleanCheckboxWidget extends WidgetBase {
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
return [
'display_label' => TRUE,
] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$element['display_label'] = [
'#type' => 'checkbox',
'#title' => t('Use field label instead of the "On label" as label'),
'#default_value' => $this->getSetting('display_label'),
'#weight' => -1,
];
return $element;
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = [];
$display_label = $this->getSetting('display_label');
$summary[] = t('Use field label: @display_label', ['@display_label' => ($display_label ? t('Yes') : 'No')]);
return $summary;
}
/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['value'] = $element + [
'#type' => 'checkbox',
'#default_value' => !empty($items[0]->value),
];
// Override the title from the incoming $element.
if ($this->getSetting('display_label')) {
$element['value']['#title'] = $this->fieldDefinition->getLabel();
}
else {
$element['value']['#title'] = $this->fieldDefinition->getSetting('on_label');
}
return $element;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Drupal\Core\Field\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Plugin implementation of the 'boolean_checkbox' widget.
*
* @FieldWidget(
* id = "boolean_checkbox",
* label = @Translation("Single on/off checkbox"),
* field_types = {
* "boolean"
* },
* multiple_values = TRUE
* )
*/
class BooleanCheckboxWidget extends WidgetBase {
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
return [
'display_label' => TRUE,
] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$element['display_label'] = [
'#type' => 'checkbox',
'#title' => t('Use field label instead of the "On label" as label'),
'#default_value' => $this->getSetting('display_label'),
'#weight' => -1,
];
return $element;
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = [];
$display_label = $this->getSetting('display_label');
$summary[] = t('Use field label: @display_label', ['@display_label' => ($display_label ? t('Yes') : 'No')]);
return $summary;
}
/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['value'] = $element + [
'#type' => 'checkbox',
'#default_value' => !empty($items[0]->value),
];
// Override the title from the incoming $element.
if ($this->getSetting('display_label')) {
$element['value']['#title'] = $this->fieldDefinition->getLabel();
}
else {
$element['value']['#title'] = $this->fieldDefinition->getSetting('on_label');
}
return $element;
}
}
Function Calls
None |
Stats
MD5 | a00a7fa9f653195ae7eb48cfd2e7bf7c |
Eval Count | 0 |
Decode Time | 93 ms |