| @@ -391,22 +391,26 @@ | ||
| 391 | 391 | $default_classes = isset( $attributes['className'] ) ? ' ' . $attributes['className'] : ''; |
| 392 | 392 | $filter_classes = apply_filters( 'srfm_field_classes', $default_classes, [ 'attributes' => $attributes ] ); |
| 393 | 393 | $field_config = apply_filters( 'srfm_field_config', [], [ 'attributes' => $attributes ] ); |
| 394 | 394 | |
| 395 | - $this->field_config = $field_config ? htmlspecialchars( Helper::get_string_value( wp_json_encode( $field_config, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ), ENT_QUOTES, 'UTF-8' ) : ''; | |
| 396 | - $this->attributes = $attributes; | |
| 397 | - $this->required = $attributes['required'] ?? false; | |
| 398 | - $this->field_width = $attributes['fieldWidth'] ?? ''; | |
| 399 | - $this->label = $attributes['label'] ?? ''; | |
| 400 | - $this->help = $attributes['help'] ?? ''; | |
| 401 | - $this->block_id = isset( $attributes['block_id'] ) ? Helper::get_string_value( $attributes['block_id'] ) : ''; | |
| 402 | - $this->form_id = isset( $attributes['formId'] ) ? Helper::get_string_value( $attributes['formId'] ) : ''; | |
| 403 | - $this->block_slug = $attributes['slug'] ?? ''; | |
| 404 | - $this->class_name = $filter_classes; | |
| 405 | - $this->placeholder = $attributes['placeholder'] ?? ''; | |
| 406 | - $this->default = $attributes['defaultValue'] ?? ''; | |
| 407 | - $this->checked = $attributes['checked'] ?? ''; | |
| 408 | - $this->options = apply_filters( 'srfm_field_options', $attributes['options'] ?? '', $attributes ); | |
| 395 | + $this->field_config = $field_config ? htmlspecialchars( Helper::get_string_value( wp_json_encode( $field_config, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ), ENT_QUOTES, 'UTF-8' ) : ''; | |
| 396 | + $this->attributes = $attributes; | |
| 397 | + $this->required = $attributes['required'] ?? false; | |
| 398 | + $this->field_width = $attributes['fieldWidth'] ?? ''; | |
| 399 | + $this->label = $attributes['label'] ?? ''; | |
| 400 | + $this->help = $attributes['help'] ?? ''; | |
| 401 | + $this->block_id = isset( $attributes['block_id'] ) ? Helper::get_string_value( $attributes['block_id'] ) : ''; | |
| 402 | + $this->form_id = isset( $attributes['formId'] ) ? Helper::get_string_value( $attributes['formId'] ) : ''; | |
| 403 | + $this->block_slug = $attributes['slug'] ?? ''; | |
| 404 | + $this->class_name = $filter_classes; | |
| 405 | + $this->placeholder = $attributes['placeholder'] ?? ''; | |
| 406 | + $this->default = $attributes['defaultValue'] ?? ''; | |
| 407 | + $this->checked = $attributes['checked'] ?? ''; | |
| 408 | + // Inject the block type slug (e.g. 'dropdown', 'multi-choice') into the attributes passed to | |
| 409 | + // the filter. The field's `slug` attribute can be prefixed when the block is inside a repeater | |
| 410 | + // (e.g. 'srfm-repeater-srfm-dropdown'), so filter consumers need a reliable block type identifier. | |
| 411 | + $block_args = [ 'block_args' => [ 'slug' => $this->slug ] ]; | |
| 412 | + $this->options = apply_filters( 'srfm_field_options', $attributes['options'] ?? '', array_merge( $attributes, $block_args ) ); | |
| 409 | 413 | $this->is_unique = $attributes['isUnique'] ?? false; |
| 410 | 414 | $this->conditional_class = apply_filters( 'srfm_conditional_logic_classes', $this->form_id, $this->block_id ); |
| 411 | 415 | $this->data_require_attr = $this->required ? 'true' : 'false'; |
| 412 | 416 | $this->block_width = $this->field_width ? ' srfm-block-width-' . str_replace( '.', '-', $this->field_width ) : ''; |
| @@ -436,9 +440,9 @@ | ||
| 436 | 440 | * @return void |
| 437 | 441 | */ |
| 438 | 442 | protected function set_input_label( $value ) { |
| 439 | 443 | $this->input_label_fallback = $this->label ? $this->label : $value; |
| 440 | - $this->input_label = '-lbl-' . Helper::encrypt( $this->input_label_fallback ); | |
| 444 | + $this->input_label = '-lbl-' . Helper::encode( $this->input_label_fallback ); | |
| 441 | 445 | $this->set_field_name( $this->input_label ); |
| 442 | 446 | } |
| 443 | 447 | |
| 444 | 448 | /** |