Skip to content

Instantly share code, notes, and snippets.

@windmitry
Last active September 5, 2016 13:33
Show Gist options
  • Save windmitry/283f7ebe529fe10fca285f44c4fc1fc3 to your computer and use it in GitHub Desktop.
Save windmitry/283f7ebe529fe10fca285f44c4fc1fc3 to your computer and use it in GitHub Desktop.
Drupal.behaviors.webformPlaceholders = {
attach:function (context, settings) {
var text_search_default = Drupal.t("Enter Here");
var inputField = $("form.webform-client-form input[type='text']");
inputField.val(text_search_default);
inputField.focus(function () {
if ($(this).val() == text_search_default) {
$(this).val('').addClass('active');
}
}).blur(function () {
if ($(this).val() == '') {
$(this).val(text_search_default).removeClass('active');
}
});
$("form.webform-client-form").submit(function () {
if (inputField.val() == text_search_default) {
inputField.val('');
}
});
}
}
// Render a user image with the default image style
render(field_view_field('user', $user, 'field_avatar'));
// and a nodes image
render(field_view_field('node', $node, 'field_image'));
// Render with a custom image style, in this case named 'post_avatar'
render(field_view_field('user', $user, 'field_avatar', array('settings' => array('image_style' => 'post_avatar'))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment