Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Category: bug » support

Yes, docs are still very lacking. It means that if there's no value in the URL, we force a drupal_goto().

It's very harcoded, we might like to add a setting to tell to which page to drupal_goto()

joachim’s picture

Where does drupal_goto() if there's no destination given? Just to the front page?

amitaibu’s picture

entityreference_prepopulate_field_attach_form() :

elseif ($settings['fallback'] == 'redirect') {
  drupal_set_message($message, 'notice');
    drupal_goto();
}
joachim’s picture

Right, but http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_goto/7 doesn't say what happens if $path is empty.

amitaibu’s picture

Indeed, it goes to the front page.

adrien.nethink’s picture

Well, it seems that drupal_goto() function uses a $_GETvariable named "destination" in order to establish the final destination url, if none is given as an argument.

function drupal_goto($path = '', array $options = array(), $http_response_code = 302) {
  // A destination in $_GET always overrides the function arguments.
  // We do not allow absolute URLs to be passed via $_GET, as this can be an attack vector.
  if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
    $destination = drupal_parse_url($_GET['destination']);
    $path = $destination['path'];
    $options['query'] = $destination['query'];
    $options['fragment'] = $destination['fragment'];
  }

FROM : http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_goto/7

So, to change the destination url, whenever you call you're edit/create node page, just add "destination=mypage/mynode" in the URL arguments to redirect you fallback.

Example:

http://mydrupalsite.com/node/add/mycontenttype?id_entity_reference_prepo...

liquidcms’s picture

wouldn't access denied be a good option for this?

liquidcms’s picture

and this patch adds Access Denied as a fallback option.

i also set msg as type error rather than notice which has been used with other options. i personally don't like the notice option for any of these fallbacks. possibly for error should be type error, maybe redirect as type warning; but even there error is likely a better fit.

sorry, this is a std diff formatted patch; not git (not changing status i guess this should be a new issue as not exactly what is being reported here)

liquidcms’s picture

hmm.. ignore patch above.. should have been simple but drupal (core bug) in what it does for drupal_access_denied() function.. will need a different method to create access denied.

liquidcms’s picture

ok, this is better

one thing i noticed about this though which i think is more of an issue with OG access control than with entref-prepop fallback is that if the og_group_ref value that is passed is for a group that the user does not have create content access for; then prepop will not have the item in the og_group_ref field list and will therefore appear as if not being filled; this in turn looks the same as no value being passed - in which case my access denied is hit and the "Field Groups audience must be populated via URL" msg is presented; which is not completely correct and is confusing to the user (since a ref was populated via the url)

i don't exactly understand when the std og access control kicks in and determines the user doesn't have access to add content to this group; possibly it is done on form submit? which seems wrong in itself - possibly a tighter integration between OG and ER-prepop is required.

drasgardian’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
2.23 KB

The attached patch gives an access denied option and also allows the redirect path to be configured rather than only redirecting back to the homepage.

Status: Needs review » Needs work
drasgardian’s picture

Status: Needs work » Needs review
FileSize
2.58 KB

update to last patch to clean up if-thens to switch and remove incorrect #required attribute.

amitaibu’s picture

Thanks for the patch - maybe we should move it to own issue?
Also it will require a simpleTest to assert the functionality.

drasgardian’s picture

Patch updated to include simpletest.

akalata’s picture

Status: Needs review » Needs work

#15 operates as expected, but the drupal_set_message call should use one of the supported message types: status, warning, error (patch uses 'notice').

akalata’s picture

Title: unclear what the 'redirect' fallback does » Improve 'redirect' fallback explaination and options
Component: Documentation » Code
Category: Support request » Feature request
Status: Needs work » Needs review
FileSize
7.42 KB

Updating issue status and title to classify the morph into a feature request.

In addition to cleaning up the issue I noticed in #15, I've added two more settings that will allow the user to set the message type (status, warning, error, or no message) and to customize the message itself, if desired.

Status: Needs review » Needs work
drasgardian’s picture

Status: Needs work » Needs review
FileSize
7.46 KB

Updated patch to check for existence of message_type

rwilson0429’s picture

Patch in #19 works well and definitely improves 'redirect' fallback explanation and options. This is a nice addition to the module's usability and functionality.

AaronBauman’s picture

Status: Needs review » Reviewed & tested by the community

bumpity bump

AaronBauman’s picture

There have been dev releases, but still this patch hasn't been included.
Anybody home?

re-rolled against latest dev.

Status: Reviewed & tested by the community » Needs work
AaronBauman’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
7.53 KB
delacosta456’s picture

hi
Patch #26 apply correctly on D7 7.69+php7.1+panopoly distro.

However i would like to know if message field or redirect field accept token usage

Thanks

delacosta456’s picture

delacosta456’s picture

hi
When using only the set form error, this doesn't prevent the node to be saved

thanks

Anybody’s picture

Confirming RTBC of #26 and say thanks for tests and reroll!

Anybody’s picture

Status: Reviewed & tested by the community » Needs work

This needs a reroll, but can be set RTBC afterwards! Please provide an interdiff.

@AaronBauman would you do that? I'd be happy to commit this then.