On my site I have a content type "File".

I've embedded the node create form in a block and placed it in the right column of a page. I did this so that when a person is on that particular page, they can create a "File" without having to go to a different page to do so.

I've created a rule with a limit on the number of nodes that can be created. The rule has 2 actions on execution:

1. redirect to the page that contains the block with the embedded node create form
2. display a message that the limit has been reached.

It does everything that it's supposed to. However, when the redirect happens, you are still able to fill out the create node form in the block...when you click "save", the rule brings you back to the page and displays the message and the content type "File" gets saved.

So, I'm wondering if this is an issue with the module or if the special circumstance of the content creation form being embedded in the block makes it impossible to use the module.

Thanks for your help!

Comments

jdwfly’s picture

A couple more things and I should be able to help you better.

1. Please export your rule and post to this issue queue.
2. Please confirm that you are using the latest dev snapshot.
3. Please explain how you are embedding the form into the right column of a page.

Thanks

zdean’s picture

1. the rule

array (
  'rules' => 
  array (
    'rules_5' => 
    array (
      '#type' => 'rule',
      '#set' => 'event_node_limitnumber_check_limit',
      '#label' => 'Limit on Number of Files Uploaded',
      '#active' => 1,
      '#weight' => '0',
      '#categories' => 
      array (
      ),
      '#status' => 'custom',
      '#conditions' => 
      array (
        2 => 
        array (
          '#type' => 'condition',
          '#settings' => 
          array (
            'roles' => 
            array (
              0 => 3,
              1 => 4,
            ),
            'operation' => 'OR',
            '#argument map' => 
            array (
              'user' => 'user',
            ),
          ),
          '#name' => 'rules_condition_user_hasrole',
          '#info' => 
          array (
            'label' => 'User has role(s)',
            'arguments' => 
            array (
              'user' => 
              array (
                'type' => 'user',
                'label' => 'User',
              ),
            ),
            'module' => 'User',
          ),
          '#weight' => -5,
        ),
        0 => 
        array (
          '#type' => 'condition',
          '#settings' => 
          array (
            'type' => 
            array (
              'file' => 'file',
            ),
            '#argument map' => 
            array (
              'node' => 'node',
            ),
          ),
          '#name' => 'rules_condition_content_is_type',
          '#info' => 
          array (
            'label' => 'Node is File',
            'arguments' => 
            array (
              'node' => 
              array (
                'type' => 'node',
                'label' => 'Content',
              ),
            ),
            'module' => 'Node',
          ),
          '#weight' => 0,
        ),
        1 => 
        array (
          '#weight' => 0,
          '#info' => 
          array (
            'label' => 'Reached limit for the node type',
            'module' => 'Node Limit Number',
            'arguments' => 
            array (
              'node' => 
              array (
                'label' => 'Node',
                'type' => 'node',
              ),
              'user' => 
              array (
                'label' => 'User',
                'type' => 'user',
              ),
            ),
          ),
          '#name' => 'node_limitnumber_rules_condition_limit',
          '#settings' => 
          array (
            'limit' => '25',
            'time' => 'none',
            '#argument map' => 
            array (
              'node' => 'node',
              'user' => 'user',
            ),
          ),
          '#type' => 'condition',
        ),
      ),
      '#actions' => 
      array (
        1 => 
        array (
          '#weight' => -3,
          '#info' => 
          array (
            'label' => 'Page redirect',
            'module' => 'System',
            'eval input' => 
            array (
              0 => 'path',
              1 => 'query',
              2 => 'fragment',
            ),
          ),
          '#name' => 'rules_action_drupal_goto',
          '#settings' => 
          array (
            'path' => 'filebank',
            'query' => '',
            'fragment' => '',
            'force' => 0,
            'immediate' => 0,
          ),
          '#type' => 'action',
        ),
        0 => 
        array (
          '#type' => 'action',
          '#settings' => 
          array (
            'message' => 'You have reached the limit of 25 file uploads. If you would like to upload any more files, you will first need to delete 1 or more files from the File Bank.',
            'error' => 0,
          ),
          '#name' => 'rules_action_drupal_message',
          '#info' => 
          array (
            'label' => 'Show a configurable message on the site',
            'module' => 'System',
            'eval input' => 
            array (
              0 => 'message',
            ),
          ),
          '#weight' => 0,
        ),
      ),
      '#version' => 6003,
    ),
  ),
)

2. I confirm that I'm using the latest dev snapshot
3. I used the following to embed the code:

global $user;

if( !function_exists("node_object_prepare")) {
   include_once(drupal_get_path('module', 'node') . '/node.pages.inc');
}
$type = 'file';

// Initialize settings:
$node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => '');

print drupal_get_form($type .'_node_form', $node);

Thanks for your help!

jdwfly’s picture

Category: bug » support

I think your problem is that you are not immediately issuing the page redirect. You need to put the configurable message as the first action and then the page redirect afterwards and make sure to select "Immediately issue the page redirect"

That should fix your problem.

zdean’s picture

I tried this but am still able to create the node.

Is there any kind of action that allows you to disable a block? That way, if the limit is reached, the block with the create form could be disabled and replaced with another block that simply has the message that the limit has been reached.

jdwfly’s picture

Status: Active » Postponed (maintainer needs more info)

Can you reconfirm this using the formblock module? If it is still allowing you to create a node I'll need to look into this more.

balsama’s picture

I can confirm that it still allows you to create a node when the form is embedded in a block using the form block module. Any ideas?

jdwfly’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Old support request and I cannot reproduce.