2

So, I'm trying to embed the form I find at '/admin/config/workflow/rules/reaction/manage/commerce_payment_paypal_wps/edit/3' - which contains the settings for the PayPal business, etc (from commerce_paypal_wps.module).

Looking in rules/ui/ui.controller.inc I can see it's called thus:

$items[$base_path . '/manage/%rules_config/edit/%rules_element'] = array(
      'title callback' => 'rules_get_title',
      'title arguments' => array('Editing !plugin "!label"', $base_count + 3),
      'page callback' => 'drupal_get_form',
      'page arguments' => array('rules_ui_edit_element', $base_count + 1, $base_count + 3, $base_path),
      'access arguments' => array('administer rules'),
      'load arguments' => array($base_count + 1),
      'file' => 'ui/ui.forms.inc',
      'file path' => drupal_get_path('module', 'rules'),
    );

I'm not entirely sure what extra things I should be passing into drupal_get_form('rules_ui_edit_element') to make it render the form as it does normally.

How on earth do I get that rules action settings form to render either through drupal_get_form, or some other mechanism, so I can put it at the URL of my choosing, and make it look a bit more presentable to our clients?

2
  • What exactly are you trying to do? This is a rules configuration form, just displaying it won't do much, the action is not executed when that form is submitted but when the corresponding event is executed.
    – Berdir
    Commented Mar 18, 2011 at 16:11
  • @Berdir: He doesn't want to invoke an event, but to change the url of the settings form, for an action/event.
    – googletorp
    Commented Mar 18, 2011 at 16:25

1 Answer 1

1

You must be using an old version of commerce to get an url like that. It was changed long ago to dmin/commerce/config/payment-methods/...

In hook_menu, the commerce_payment_ui module creates the path, where the rules forms should be located:

// Add the menu items for the various Rules forms.
$controller = new RulesUIController();
$items += $controller->config_menu('admin/commerce/config/payment-methods');

You could alter those if you want to change the url. You should however be aware that this url is also used elsewhere:

/**
 * Builds the payment settings page using the Rules UI overview table filtered
 *   to display payment method rules.
 */
function commerce_payment_ui_admin_page() {
  RulesPluginUI::$basePath = 'admin/commerce/config/payment-methods';

  ...
}

Since most of what Rules does, including creating these settings form is classed based, it wont exactly be easy to create the form. I haven't delved much into the Rules code, but I remember seeing public functions called

  • form
  • form_validate
  • form_submit

I believe these are used to create the form, but how it ends up in the FAPI is beyond me. If all you want is to change the path, you could just use hook_menu_alter and for commerce, overwrite the commerce_payment_ui_admin_page function with your own to create the overview table.

1
  • Turns out I was going through the Rules UI rather than the Commerce Payment UI, which gave me the old URL structure - we're on the Commerce Beta. I guess the right way to go, then, is to menu_alter the original rule form, and then form_alter it to look better (add our own validation, etc), and make sure form_submit for that rule gets called. Commented Mar 21, 2011 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.