Created a custom component as a separate module (see attached). Admin functions work as expected, but component doesn't render on client form.

Component is present in $form["components"] at the end of webform_client_form function;
$show_component = 1 at end of _webform_client_form_rule_check function;
Component not present in rendered HTML.

Have I missed something obvious, or is this a bug?

CommentFileSizeAuthor
#3 webform_phone.tar_.gz9.55 KBvernond
webform_phone.tar_.gz8.84 KBvernond

Comments

quicksketch’s picture

Category: bug » support

In _webform_render_phone(), you can't have this line of code:

'#type' => $component['type'],

Form API is not aware of a 'phone' element type. As I found out recently, you'll need to implement hook_elements() to make this work well. I'd suggest calling your new element "webform_phone" to match what I've done for Grid and Time components. See this issue and the second patch #1150576: The "time" component should use a #process function for expanding itself.

Please file questions about your own code as a support request, not a bug. According to the submission guidelines I don't help with custom code, but I'm always glad to see new components so this is a bit of an exception.

vernond’s picture

Ah, okay, sorry about that. Thanks for the heads-up on hook_elements and FAPI

vernond’s picture

Title: Custom component not rendering on client form » Custom Phone Number component not rendering on client form
Status: Active » Closed (fixed)
StatusFileSize
new9.55 KB

Sorted - see attached if interested