New to the forum, looking for some technical help (drupal_execute)!

Hello all,

I've just joined the forums, as I am having some issues with drupal and I just can't resolve it! I've already tried looking for help at drupal.org, but it seems no one can help (Frown).

I was hoping this community might be able to help me out!

Below is a copy of my problem:

I'm currently working on a website, and they have quite a large ContentType ('property'). The users of the websites (landlords) will be submitting properties to the website.

Landlords are quite confused by the default property_node_form form, as it is quite long. To improve the process of Landlords uploading their properties I am writing a module which will basically render parts of the node form in turn, building up the full node dataset across 3 or 4 pages.

I am having problems running drupal_execute when I try and submit these partial forms. Here are the core parts of my code (it's pretty hacky!)

<code>
/** hook menu **/
function property_upload_menu() {
    $items = array();
   
    $items['landlords/new-property'] = array(
        'title' => 'Advertise a New Property',
        'description' => 'Displays a multistage form for adding a property',
        'page callback' => 'new_property_stage1',
        'access arguments' => array('access landlord account'),
        'type' => MENU_CALLBACK,
    );
   
    return $items;
}

/** menu callback **/
function new_property_stage1() {
    $_SESSION['new-property'] = null;
    drupal_add_js(path_to_theme()."/js/new-property.js");
    global $user;
   
    $output = _render_tabs(1);
    $output.= "<h1>Step 1. Property Address</h1>";
    $output.= "<div class='add-property-step1'>";
   
    $output.= "<br /><p>To start uploading your property, please enter the address below.</p>";
   
    $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => 'property', 'language' => '');
    $output.= drupal_get_form('property_node_form', $node);
    $output.= "</div>";
   
    return $output;
}

/** hook form_alter **/
function property_upload_form_alter(&$form, $form_state, $form_id) {
    $paths = array('landlords/new-property');
    if(in_array($_REQUEST['q'], $paths)) {
        if($form_id=='property_node_form') {
            // Hide blocks we dont want for stage 1
            // we will have a switch() statement here to decide which page we're on...
            // for now lets just get page 1 working...
            $form['path']['#access'] = false;
            $form['options']['#access'] = false;
            $form['comment_settings']['#access'] = false;
            $form['body_field']['#access'] = false;
            $form['menu']['#access'] = false;           
            $form['author']['#access'] = false;
            $form['nodewords']['#access'] = false;
            $form['revision_information']['#access'] = false;
            $form['group_availability']['#access'] = false;
            $form['group_feeddata']['#access'] = false;
            $form['group_cost']['#access'] = false;
            $form['group_description']['#access'] = false;
            $form['group_tenancy']['#access'] = false;
            $form['field_image']['#access'] = false;
           
            // Need to remove date validates...
            $form['group_availability']['field_available_from'][0]['#element_validate'] = null;
           
            // Set actual validation / submission functions
            $form['#submit'] = array('stage1_submit');
            $form['#validate'] = array('stage1_validate');
        }
    }
}

/** property_node_form_validate **/
function stage1_validate(&$form, &$form_state) { } // All neccessary validation is handled by required fields...

/** property_node_form_submit **/
function stage1_submit($form, $form_state) {
    global $user;
    $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => 'property', 'language' => '');
   
    $submission = array();
    $submission['values'] = array(
        'field_housenumber' => $form_state['values']['field_housenumber'],
        'locations' => $form_state['values']['locations']
    );
   
    drupal_execute('property_node_form', $submission, (object)$node);
}
</code>

The form is drawn nicely, the validation callback is fired, then the submit callback is fired. Which then gives this error:

<code>Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 51 bytes) in C:\xampp\htdocs\lap-phase4\includes\form.inc on line 1056</code>

My memory limit is 96mb, which really is enough to submit a form!

Obviously this behaviour is being caused by my hacking apart of the node form. Can anyone offer any ideas on how I can fix this? In the mean time, I shall have a play around!

In stage1_submit() I was originally passing $form_state directly to the drupal_execute() function, then I just took the elements I wanted and stored them in $validate and tried passing that to drupal_execute(). The result was:

<code>Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 35 bytes) in C:\xampp\htdocs\lap-phase4\includes\common.inc on line 2974</code>

Cheers,
Dave

BOZMAN's picture

memory limit

did you try increasing your memory limit?

i found some of my sites using taxonomy access will only run smoothly with 256M.

i would have thought 96M is the bare minimum#

 

boz