Skip to content

Commit

Permalink
[bw_contact_field] - Add support for value and placeholder attributes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Sep 6, 2022
1 parent 18b53f7 commit e421d57
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shortcodes/oik-contact-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function bw_contact_field( $atts, $content, $tag ) {
*/
$args = [ '#length' => 30 ];
$value = bw_array_get( $atts, 'value', null);
$args['value'] = $value;
$args['#default'] = $value;
$placeholder = bw_array_get( $atts, 'placeholder', null );
$args['#placeholder'] = $placeholder;

/**
* Sets the required flag in #extras if the Label contains a '*' or the
Expand All @@ -70,8 +72,9 @@ function bw_contact_field( $atts, $content, $tag ) {
// The next line of code is used for testing.
//bw_form_field( $full_name, $type, $label, $value, $bw_fields[ $full_name ]);

$html = bw_ret();

// The contact field is not expected to produce output itself. It's used in the contact form.
$html = bw_ret();
return $html;
}

Expand All @@ -96,13 +99,12 @@ function bw_contact_field_type_from_name( $name ) {
$types = [ 'name' => 'text'
, 'email' => 'email'
, 'subject' => 'text'
, 'telephone' => 'telephone'
, 'telephone' => 'tel' // Not yet supported by bw_form_field()
, 'message' => 'textarea'
, 'text' => 'textarea'
];
$type = bw_array_get( $types, $name, 'text');
return $type;

}

/**
Expand Down

0 comments on commit e421d57

Please sign in to comment.