πŸ‡ΊπŸ‡ΈUnited States @spivey

Account created on 21 August 2009, almost 15 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States spivey

The only datetype that should be in use is whatever datatype the Date/ Time element uses. I'm not using any custom fields or elements from outside Webforms.

πŸ‡ΊπŸ‡ΈUnited States spivey

I see the logic in not classifying it as a bug however I do not this is supposed to work how it is working. I've updated this is issue to reflect it is not a bug however I'm still not clear on how to solve the problem.

πŸ‡ΊπŸ‡ΈUnited States spivey

I'm not sure what you mean by that, but I changed the code in the "Computed Field/ Markup" to only have:
{% set startDate = webform_token('[webform_submission:values:start_date_and_time:raw:clear]', webform_submission) ?: 0 |date('d.m.Y H:i:s') %}

Filled the form out and received the same errors.

πŸ‡ΊπŸ‡ΈUnited States spivey

Is there anything I can do to move past this?

πŸ‡ΊπŸ‡ΈUnited States spivey

This sort of code for working with field values is different on D8/9/10.

Which is why I'm requesting help. The documentation for the D6 version was much more compete with code examples.

πŸ‡ΊπŸ‡ΈUnited States spivey

If this isn't a valid support request do I need to reach out to a developer or contracted help?

πŸ‡ΊπŸ‡ΈUnited States spivey

I'm still completely lost. I'm guessing the custom code needs to go here:

public function computeValue(EntityInterface $host_entity, ComputedFieldDefinitionWithValuePluginInterface $computed_field_definition): array {
    // Returns the value for a computed field.

Coming from D6 I had this in the PHP computed code block:
$node_field[0]['value'] = date_difference($node->field_calltime[0]['value'],$node->field_calltime[0]['value2'], 'hours',DATE_DATETIME);

Formatted with:
$display = $node_field_item['value'];

fieldcalltime[0] 'value' and 'value2' are the 2 values store in the date range field 'field_calltime'. Does this translate at all into ComputedField version 3?

πŸ‡ΊπŸ‡ΈUnited States spivey

You will now need to examine the generated plugin file. Some methods may be removed depending on your use case.

The code that produces the value for the field should go in the computeValue() method. If your field is single-valued, you can use the SingleValueTrait to simplify the return value.

I've been over that several times; which is why I came here to ask if there are any examples of calculations being performed. Is there anything like that in the test directories? From what I can see there's only samples of variables being declared or strings generated.

πŸ‡ΊπŸ‡ΈUnited States spivey

@spivey do you mean like shown here: https://www.php.net/manual/en/datetime.diff.php

If that's the best way to do it, sure. I'm not quite sure how or where to enter that. I'm coming from ComputedField in D6, where the code was a little easier for me to adapt.

πŸ‡ΊπŸ‡ΈUnited States spivey

Are there any examples of how to perform calculations? I believe I'm following everything with regards to the custom module and plugins but I cannot find examples of finding the difference between to values. Essentially I have a "start" date with time and a "end" date with time and need to return the difference between the two. Some instances I just need the number of days, others it needs to be in hours.

Production build 0.69.0 2024