public function Fraction::buildOptionsForm in Fraction 8
Same name and namespace in other branches
- 2.x src/Plugin/views/field/Fraction.php \Drupal\fraction\Plugin\views\field\Fraction::buildOptionsForm()
@inheritdoc
Overrides FieldPluginBase::buildOptionsForm
File
- src/
Plugin/ views/ field/ Fraction.php, line 35
Class
- Fraction
- Field handler for Fraction database columns.
Namespace
Drupal\fraction\Plugin\views\fieldCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
// Add fields for configuring precision and auto_precision.
$form['precision'] = [
'#type' => 'textfield',
'#title' => t('Precision'),
'#description' => t('Specify the number of digits after the decimal place to display when converting the fraction to a decimal. When "Auto precision" is enabled, this value essentially becomes a minimum fallback precision.'),
'#default_value' => $this->options['precision'],
];
$form['auto_precision'] = [
'#type' => 'checkbox',
'#title' => t('Auto precision'),
'#description' => t('Automatically determine the maximum precision if the fraction has a base-10 denominator. For example, 1/100 would have a precision of 2, 1/1000 would have a precision of 3, etc.'),
'#default_value' => $this->options['auto_precision'],
];
// Merge into the parent form.
parent::buildOptionsForm($form, $form_state);
// Remove the 'click_sort_column' form element, because we provide a custom
// click_sort function below to use the numerator and denominator columns
// simultaneously.
unset($form['click_sort_column']);
}