-
Sending webform submissions to email based on value of field
We recently did a site for a client that allowed patients to submit a webform to request an appointment. The user could choose their physician and based on their choice, the submission would be emailed to the chosen doctor’s secretary. I originally thought about using the key part of the key|value pair for the select list to store the secretary’s email address, with the doctor’s name. This wouldn’t work, however, because the key could not contain standard email address characters. The solution involved isn’t exactly dynamic, but for a select list that won’t change much (the case here), it’s a fairly elegant solution. Here is the select list and associated code. I created this with the webform UI using a simple select list webform field.
-
Using hook_form_alter() and #after_build to set maxlength on emvideo title field
A fellow Drupal user posted an issue to the Embedded Media Field project. The user was trying to set the maxlength from 35 characters to some other number for the ‘title’ field within each embedded video widget. I faced the same issue with a site. The client wanted to be able to add more lengthy captions to each video they uploaded. I added the embedded video field (YouTube) as an “unlimited” video field.
The solution involves using hook_form_alter() and the #after_build property.
1234567891011121314151617181920212223242526272829/*** Implementation of hook_form_alter().*/function mymodule_form_alter(&$form, &$form_state, $form_id) {switch ($form_id) {case 'vgallery_node_form':$form['#after_build'][] = '_vgallery_after_build';break;}}/*** Custom after_build callback handler for the video gallery node form*/function _vgallery_after_build($form, &$form_state) {_vgallery_set_title_maxlength($form['field_vgallery_videos']);return $form;}/*** Set the maxlength on the title field of a video gallery emvideo element*/function _vgallery_set_title_maxlength(&$elements) {foreach (element_children($elements) as $key) {if (isset($elements[$key]['emvideo']['title'])) {$elements[$key]['emvideo']['title']['#maxlength'] = 255;}}}