Using hook_webform_component_render_alter() I am setting the default values for some components on a webform if a user has the corresponding fields in his/her profile filled out.

if($component['cid'] == 24){
    $element['#default_value'] = $myValue; 

This works for every type of webform component thus far until I used a Webform Structured Textfield.

When I add the same code to the Webform Structured Textfield It only takes one digit from the number i'm assigning it. My input mask for the field is: 9999999 allowing the user to only enter 7 digits.

For simplicity sake, I have a variable: $myValue = 1234567;

When I assign the $myValue variable to the webform component the textfield will only show the value 1 instead of the 1234567. When I assign the variable to other webform components the value 1234567 is shown.

Is there anything I am missing or doing wrong when assigning default values to a Webform Structured Textfield? And if anyone knows any other ways to modify this field programmatically that would be sufficient as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.