Problem/Motivation

bee_form_alter()'s node edit-form branch (matched by preg_match('/^node_.*_edit_form$/', $form_id)) unconditionally sets, for hourly bookable types with payment enabled:

$form['field_price_frequency']['widget']['#default_value'] = 'hour';

Because this branch only ever runs on edit forms — never the node add form — this line cannot act as a default for new nodes. Its only observable effect is replacing the entity's stored field_price_frequency value in the widget. A node priced per minute renders its edit form with "Hour" pre-selected, so any routine content edit (fixing a typo, adding an image, anything) silently flips the stored value back to hour on save.

The damage compounds with BEE's own price calculation: the hour frequency computation truncates to whole hours, so a node whose bookings are shorter than an hour (e.g. fixed 30-minute slots) starts pricing every booking at 0.00 after the edit — silently, with no indication anything changed.

Steps to reproduce

1. Create an hourly bookable node type with payment enabled.
2. On a node of that type, set field_price_frequency to minute (e.g. per-minute pricing for 30-minute slots) and set a price.
3. Edit the node: the Payments section shows "per Hour" even though the stored value is minute.
4. Save the form without touching the price fields.
5. The stored value is now hour; a sub-hour reservation of this node now computes a 0.00 price.

Proposed resolution

Remove the #default_value override — the options widget already carries the entity's stored value, like every other field on the form. If a default for new nodes is intended, it belongs in the field definition (bee_add_price_frequency_field()) or in an add-form branch, not the edit-form branch.

 --- a/bee.module
 +++ b/bee.module
 @@
            $form['field_price_frequency']['#group'] = 'payments';
 -          $form['field_price_frequency']['widget']['#default_value'] = 'hour';
            $form['field_price_frequency']['widget']['#title'] = t('per');
            unset($form['field_price_frequency']['widget']['#options']['_none']);

Verified on 11.1.0-rc3 (line 303) and still present at HEAD: after removing the line, the edit form shows the stored value, a full form save leaves the entity unchanged, and sub-hour pricing keeps working after staff edits.

Remaining tasks

Review; decide whether a new-node default should be added elsewhere.

API changes

None.

Data model changes

None. (Existing sites that already lost values to this bug need to re-set field_price_frequency on affected nodes — the bug leaves no trace, so affected values must be found by inspection.)

Comments

paddy_deburca created an issue.