In rules/rules/modules/system.rules_forms.inc on line 79 we have a textfield:

/**
* Action "Send a mail to an arbitrary mail address" configuration form
*/
function rules_action_mail_form($settings = array(), &$form) {
  $form['settings']['to'] = array(
    '#type' => 'textfield',
    '#title' => t('Recipient'),
    '#default_value' => isset($settings['to']) ? $settings['to'] : '',
    '#description' => t("The mail's recipient address. You may separate multiple addresses with ','."),
    '#required' => TRUE,
    '#weight' => -1,
  );
  rules_action_mail_to_user_form($settings, $form);
}

Changing textfield to textarea allows you to use a much longer php snippet in the recipient field. In my case, I needed to send an email to 4 addresses stored in 4 different CCK fields. I think this would be a reasonable change for release.

Thanks and loving the module,
--
Dan

Files: 
CommentFileSizeAuthor
#14 448922-recipients-as-textarea.patch795 byteshanoii
PASSED: [[SimpleTest]]: [MySQL] 13 pass(es).
[ View ]

Comments

Title:Allowing more php in the recipient field for "Send a mail to an arbitrary mail address" actionText input elements are too small!
Version:6.x-1.0-rc1» 6.x-1.x-dev
Component:Rules Core» Rules Engine
Category:feature» task
Status:Needs review» Active

Hm, yep that's not ideal. However most user don't need more place there, so I prefer to keep it as it is. As a workaround one can add a new string variable beforehand and than add in its value here using php input evaluation. Though a js solution to increase text input elements similar to that one of the textarea might make sense.

Title:Text input elements are too small!Make text inputs expandable
Category:task» feature

Changing title and category.

Priority:Normal» Minor

I need it also bigger :-)

Why not make textarea of 1 row and make it expandable, so if someone needs it he can make it bigger, but its smalled by def.

p.s.

first post works.

Subscribing.

+1 for textarea with 1 visible line by default; or at least removal 128 chars bar (don't know if it is possible)

Any complex evaluation takes me more than 128 chars.

The php is needed to perform actions that are more complex that 128 characters can hold AND many of the cck field names may be very very long.

For example, I cannot but need to do this:
<?php if (db_query("select name from users where name = LOWER('%s')", "[node:field_register_00001_00001-formatted]")){ print("1"); } else { print("0"); } ?>

Version:6.x-1.x-dev» 6.x-1.3

+1 for textarea with 1 visible line by default; or at least removal 128 chars bar (don't know if it is possible)

+1

If all you want to do is remove the 128 character limit, then all you should need to do is redefine the maxlength of the string input form, right?

The following change seems to work for me:

Old Code (rules/rules/modules/rules.rules.inc)

/**
* Rules string data type
*/
class rules_data_type_string extends rules_data_type {
  /**
   * Gets the input form for the data
   * Implement it, if your data is not identifiable.
   */
  function get_default_input_form($info, $value, &$form_state) {
    $info += array('long' => FALSE, 'required' => TRUE, 'description' => '');
    return array(
      '#type' => $info['long'] ? 'textarea' : 'textfield',
      '#title' => $info['label'],
      '#description' => $info['description'],
      '#required' => $info['required'],
      '#default_value' => $value,
    );
  }
}

New Code (rules/rules/modules/rules.rules.inc)

/**
* Rules string data type
*/
class rules_data_type_string extends rules_data_type {
  /**
   * Gets the input form for the data
   * Implement it, if your data is not identifiable.
   */
  function get_default_input_form($info, $value, &$form_state) {
    $info += array('long' => FALSE, 'required' => TRUE, 'description' => '');
    return array(
      '#type' => $info['long'] ? 'textarea' : 'textfield',
      '#title' => $info['label'],
      '#description' => $info['description'],
      '#required' => $info['required'],
      '#default_value' => $value,
      '#maxlength' => 256,
    );
  }
}

+1

The problem is that the length is different from case to case and having a hardcoded limit is the problem.

I end up having to type PHP in a number of these forms and they can be very complex, depending on the situation.

The change in #10 still has a max limit, its just at 256.
That is unfortunately still a problem.

I think a textarea is needed here instead of a textfield.

FYI: I think this is what is done with the drupal 7 version of this module.

@kevinday -

You're right that my solution is probably less ideal for most users than simply changing the input to a textarea. All I meant to call out was where to make changes in the structure of this module. If you want to change the input type (e.g. textfield to textarea), then it's pretty clear where to change that in the form.

However, if you just want to increase the character limit from 128, looking in 'system.rules_forms.inc' won't help; you have to redefine how a textfield input is defined. My post was meant to highlight that fact, especially as this thread comes up pretty high in a google search for anything related to rules and max characters.

Title:Make text inputs expandableMake recipient input expandable
Version:6.x-1.3» 6.x-1.4
Category:feature» bug
Status:Active» Needs review
StatusFileSize
new795 bytes
PASSED: [[SimpleTest]]: [MySQL] 13 pass(es).
[ View ]

I think this should be consider a bug. If the rule is meant to send emails to multiple recipients and you cannot add enough recipients because of the maxlengh limitations, and evenmore, if you are also allow to use PHP code in there and you can't because of the space, then is a bug. It might not be for most users but definitely for some.

Attached is a patch that implements what was suggested in #0. I tried it and it does seem like a solution that will merge both simple and advanced uses.

I am changing the title as this issue only address this specific field which is probably one of the few that needs expanding. I guess we can address other fields on separate issues? If I am a bit off with that, I apologize and please restore title.

Status:Needs review» Fixed

thanks, I've committed the patch from #14. Fixing this in situations where a longer input is likely to be needed often, makes sense to me.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.