class FormElement in Modules weight 8
Same name and namespace in other branches
- 8.2 src/Utility/FormElement.php \Drupal\modules_weight\Utility\FormElement
Provides Form Element helper methods.
Hierarchy
- class \Drupal\modules_weight\Utility\FormElement
Expanded class hierarchy of FormElement
2 files declare their use of FormElement
- FormElementTest.php in tests/
src/ Unit/ Utility/ FormElementTest.php - ModulesListForm.php in src/
Form/ ModulesListForm.php
File
- src/
Utility/ FormElement.php, line 10
Namespace
Drupal\modules_weight\UtilityView source
class FormElement {
/**
* Prepares the delta for the weight field.
*
* If a module has a weight higher then 100 (or lower than 100), it will use
* that value as delta and the '#weight' field will turn into a textfield most
* likely.
*
* @param int $weight
* The weight.
*
* @return int
* The weight.
*/
public static function getMaxDelta($weight) {
$delta = 100;
// Typecasting to int.
$weight = (int) $weight;
if ($weight > $delta) {
return $weight;
}
if ($weight < -100) {
return $weight * -1;
}
return $delta;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormElement:: |
public static | function | Prepares the delta for the weight field. |