Hi,

I'm attempting to use this module to prepopulate a field on a node edit form. The node already exists & its URL is rewritten by the Pathauto module , & its edit URL is rewritten by the Subpath Auto module. So:

The node's actual node nid is 207 & its Pathauto-rewritten URL is /gaylords/3.

Its edit page is at /gaylords/3/edit.

Due to the requirements of the site design, I cannot access the node edit form via its unaliased URL. Attempting to use the Prepopulate URL function with the rewritten URL doesn't seem to work. Am I missing something? Is there a way to make Prepopulate work with URLs that don't have the form ?edit or &edit?

Regards,
Henry

Comments

Anonymous’s picture

Status: Active » Closed (works as designed)

Well I figured it out, & it works. This is the URL that worked:

https://somesite.com/gaylords/3/edit?edit[field_gaylord_received_term][und]=gaylord_received

https://somesite.com/gaylords/3/edit is the URL alias created by Subpath Auto & appending the ?edit[field_gaylord_received_term][und]=gaylord_received to it worked.

However, the URL was being passed to the node by an Entityform form & it was producing urlencoded characters that prevented Prepopulate from working. My fix was to insert the following into a custom module using hook_form_alter to take over the Entityform's redirect on submit function & use one that passed a urldecoded URL. Like so:

  function formalter_form_alter(&$form, $form_state, $form_id) {
    switch ($form_id) {
case 'receive_gaylord_entityform_edit_form':

$form['actions']['submit']['#submit'][0] = 'gaylord_receive_entityform_submit_redirect';

function gaylord_receive_entityform_submit_redirect(&$form, &$form_state) {
$gaylordnumber = $form_state['values']['field_receive_gaylord_number']['und'][0]['value'];
$custom_url = (urldecode(url('https://somesite.com/gaylords/' . $gaylordnumber . '/edit?edit[field_gaylord_received_term][und]=gaylord_received')));
$form_state['redirect'] = $custom_url;
}
        break;
}
}

Maybe this will help somebody else in future. By the way, the field I am prepopulating is a term reference field, autoselect tag widget, & I'm inserting the term rather than the term ID.

Cheers,
H.