Reputation: 35
I am using the following code in functions.php file. It's generating placeholder correctly. but value is not coming. I have used
$args['defaultval'] == "Value"; and $args['default'] == "Value";
But Nothing worked. Help me out this
add_filter('woocommerce_form_field_args', 'custom_form_field_args', 10, 3);
function custom_form_field_args($args, $key, $value) {
if ($args['label'] == "t_size") {
$args['defaultval'] == "Value";
$args['placeholder']="Place";
}
return $args;
}
Upvotes: 0
Views: 599
Reputation: 3816
Use default
instead of defaultval
Look here, this are the deafault args:
$defaults = array(
'type' => 'text',
'label' => '',
'description' => '',
'placeholder' => '',
'maxlength' => false,
'required' => false,
'autocomplete' => false,
'id' => $key,
'class' => array(),
'label_class' => array(),
'input_class' => array(),
'return' => false,
'options' => array(),
'custom_attributes' => array(),
'validate' => array(),
'default' => '',
);
And here it will be used:
if ( is_null( $value ) ) {
$value = $args['default'];
}
If $args['default']
not used, then the condition if ( is_null( $value ) )
isn't true.
Upvotes: 1