Skip to content

Commit

Permalink
Fixed default value not set
Browse files Browse the repository at this point in the history
  • Loading branch information
overclokk committed Dec 28, 2019
1 parent 5b92278 commit f06736e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Settings/Sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,18 @@ private function addSettingsFields( $section ): void {
}
}

/**
* @todo Creare test per il `value` da usare in caso non sia ancora salvato nelle options, cazzarola
* @param array $field
*/
private function parseFieldWithDefault( array &$field ) {
$field = \array_merge( [
'show_on' => true,
'label_for' => $this->getStringForLabel( $field ),
'class' => '',
self::LABEL_CLASS => '',
'callback' => null,
'value' => '',
], $field );
}

Expand All @@ -184,7 +189,7 @@ public function renderField( array $args ) {

$args['class'] = $this->field_class[ $args['id'] ];

$args['value'] = $this->options_values[ $args['id'] ] ?? '';
$args['value'] = $this->options_values[ $args['id'] ] ?? $args['value'];
$args['id'] = $args['name'] = $this->getStringForLabel( $args );
echo $this->fields->render( $args ); // XSS ok.
return '';
Expand Down

0 comments on commit f06736e

Please sign in to comment.