How to remove the text that showing below the field "The subscriber's email address." please, its useless, thanks
sss

Comments

freelylw created an issue. See original summary.

mohit.bansal623’s picture

Status: Active » Needs review
StatusFileSize
new516 bytes

Removed description as per the requirement.

Status: Needs review » Needs work

The last submitted patch, 2: 3191672-2.patch, failed testing. View results

mohit.bansal623’s picture

Status: Needs work » Needs review
aritrika.d’s picture

I have uploaded before and after image of applying the patch,the patch works fine

tr’s picture

Status: Needs review » Needs work

Removing the base field description from the entity like the patch in #2 does is absolutely the wrong way to do this. The field descriptions are used in more than just that one place, you know, and are essential parts of the entity definition. If you think *showing* the description in that one particular place is "useless", then that's something you can easily customize on your site - no change to this module is necessary. Just hook_form_alter() the form or the block or the entity that displays the description. Or even just use CSS to hide it. Any of these ways is only a few lines of code. Regardless, I don't know why you would want to throw away descriptive text - that just increases the chance that a user enters the wrong thing.

I recommend closing this as "won't fix" because this sort of customization shouldn't be done in the simplenews module.

vikashsoni’s picture

@mohit.bansal623 this patch is working fine sharing screenshot for reference ....

robcarr’s picture

I agree that this should be something that should be done in the theme layer. However, there's not much guidance on how to achieve this.

The 3.x version doesn't provide a template for the signup block/form that can be overridden (see #3259543: Documentation wrong for Simplenews Block Theming). Currently struggling to use hook_form_alter() to change values for the description and add placeholder text; I would have expected the following to work:

function mytheme_form_alter(&$form, &$form_state, $form_id) {
  
  if($form_id == 'simplenews_subscriptions_block_simplenews-signup'){
    $form['mail']['description'] = "My description";
    $form['mail']['#attributes']['placeholder'] = 'Subscriber email address';
  }
}

But it doesn't. Whilst the Form ID is correct, I'm not sure I'm targeting the correct input element (have also tried $form['mail']['widget']['#description'] and assorted variations). So it looks like only way to deal with customisation is the very 'hacky' way at #2

robcarr’s picture

What a difference a cup of tea makes. The following code in your custom theme allows you to override the input field attributes on the signup block:

/**
 * Implements hook_form_alter()
 */
function MYTHEME_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'simplenews_subscriptions_block_simplenews-signup'){
    $form['mail']['widget'][0]['value']['#title'] = "My title";
    $form['mail']['widget'][0]['value']['#description'] = "My description";
    $form['mail']['widget'][0]['value']['#attributes']['placeholder'] = "My placeholder";
  }
}

EDIT: The simplenews-signup suffix to the form ID comes from the unique ID when you add the block to your region/page via the UI.

portulaca’s picture

Title: remove text - "The subscriber's email address." » Change Subscription Block Form; remove text - "The subscriber's email address."; add placeholder

Thank you @robcarr for posting this! It works!

For anyone also looking to change the Submit button text and adding a title attribute to it:

<?php
/**
 * Implements hook_form_alter().
 */
function mytheme_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'simplenews_subscriptions_block_simplenews_mycategory') {
    $form['actions']['submit']['#value'] = t('Notify me');
    $form['actions']['submit']['#attributes']['title'] = t('Receive email reminders about new articles published on this site');
    $form['mail']['widget'][0]['value']['#attributes']['placeholder'] = 'myemail@example.com';
  }
}
?>