Skip to content

Commit

Permalink
fixed unique form id generation
Browse files Browse the repository at this point in the history
  • Loading branch information
pryley committed Oct 25, 2024
1 parent d2c26f2 commit b9ecc21
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plugin/Modules/Html/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ class Form extends \ArrayObject implements FormContract

public function __construct(array $args = [], array $values = [])
{
$defaults = [
$args = wp_parse_args($args, [
'button_text' => __('Submit Form', 'site-reviews'),
'button_text_loading' => __('Submitting, please wait...', 'site-reviews'),
'id' => glsr(Sanitizer::class)->sanitizeIdHash(''),
];
$this->args = glsr()->args(wp_parse_args($args, $defaults));
]);
if (empty($args['id'])) {
$args['id'] = glsr(Sanitizer::class, ['values' => $args])->sanitizeIdHash('');
}
$this->args = glsr()->args($args);
$this->loadSession($values);
parent::__construct($this->fieldsAll(), \ArrayObject::STD_PROP_LIST | \ArrayObject::ARRAY_AS_PROPS);
array_map([$this, 'normalizeConditions'], $this->fields());
Expand Down Expand Up @@ -342,6 +344,7 @@ protected function normalizeFieldValue(FieldContract $field): void
} else {
$value = Cast::toString($this->session->values[$field->original_name] ?? '');
}
glsr_log($this->session->values);
if (empty($value)) {
return;
}
Expand Down

0 comments on commit b9ecc21

Please sign in to comment.