class DateDefault in Conditional Fields 8
Same name and namespace in other branches
- 4.x src/Plugin/conditional_fields/handler/DateDefault.php \Drupal\conditional_fields\Plugin\conditional_fields\handler\DateDefault
Provides states handler for date combos.
Plugin annotation
@ConditionalFieldsHandler(
id = "states_handler_datetime_default",
)
Hierarchy
- class \Drupal\conditional_fields\ConditionalFieldsHandlerBase implements ConditionalFieldsHandlersPluginInterface
- class \Drupal\conditional_fields\Plugin\conditional_fields\handler\DateDefault
Expanded class hierarchy of DateDefault
File
- src/
Plugin/ conditional_fields/ handler/ DateDefault.php, line 17
Namespace
Drupal\conditional_fields\Plugin\conditional_fields\handlerView source
class DateDefault extends ConditionalFieldsHandlerBase {
/**
* {@inheritdoc}
*/
public function statesHandler($field, $field_info, $options) {
$state = [];
$value = $this
->getWidgetValue($options['value_form']);
$date_obj = new DrupalDateTime($value);
switch ($options['values_set']) {
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET:
// Just split DATETIME_DATETIME_STORAGE_FORMAT on date and time.
$date = $date_obj
->format(DateTimeItemInterface::DATE_STORAGE_FORMAT);
// TODO: Support time.
// Need to check selector and create one more state for it.
// $time = $date_obj->tesformat('H:i:s');.
$state[$options['state']][$options['selector']]['value'] = $date;
break;
default:
break;
}
return $state;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConditionalFieldsHandlerBase:: |
public | function |
Get values form the condition options Overrides ConditionalFieldsHandlersPluginInterface:: |
|
ConditionalFieldsHandlerBase:: |
public | function |
Get values from widget settings for plugin. Overrides ConditionalFieldsHandlersPluginInterface:: |
5 |
DateDefault:: |
public | function |
Executes states handler according to conditional fields settings. Overrides ConditionalFieldsHandlersPluginInterface:: |