1
votes

Appending /createObject?type_name=Document&id=some_id_value to an folderish object's URL works. However trying the same with other field-names, doesn't: /createObject?type_name=Document&title=some_title_value, will not work, neither with the uppercased field-name Title, instead of title.

Then, I wanted to read the value of the URL with Javascript on the edit-form and insert it into the title-field, but the URL is redirected to /portal_factory/Document/document.2015-08-25.2537358109/edit, so the parameter isn't available anymore, then.

So now, I was about to manipulate the browser's history, to be able to read it of window.referral, but that's very bad practice.

Is it possible at all, to pass a title to the createObject-method or is there any other possible solution known without the need, to have the edit-form be customized, respectively create a dedicated one?

A Dexterity-solution would be welcome, too.

Update:

What I would actually like to know, is the last location of which the link ("Add page") was clicked. That gets lost, due to the redirect.

Relates to:

Provide a default value on a field also on edit form

1
I had the same need come years ago, for what I remember unluckily createObject (and the old invokeFactory also) are not passing parameters to the edit form so it's not populated. Please note: if you find a way to obtain this feature, it can be probably a security risk (CSRF) and it will probably not work on Plone 5 due to dev.plone.org/ticket/13679 - keul
Actually I don't want to send a POST-request, just have a dynamic default-val and am (mis-)using an URL-para to transport that value. The form is then sended as usual by the user (or not), that shouldn't be an security-issue, non? My only culprit is, that due to the redirection, the referrer gets lost. Thanks for the important info about inhibiting CSRF. - Ida
@keul: Feel free to post you comment as answer, so I can accept it. "Not possible" is a legit answer :-) BTW: My reqs changed by now, I'm loading the form into the context and can grab the value of the current page, then. - Ida
With archetypes at least, the edit form has a hidden field last_referer, but that includes the view. - Ulrich Schwarz
@UlrichSchwarz: Oh, indeed. That wouldn't solve the redirection-culprit, though. I wonder what this hidden inputs-purposes are for. Done as a link, they'll be a perfect backwards-button in the UI. Interesting, thanks. - Ida

1 Answers

1
votes

You could customize portal_skins/plone_scripts/createObject/manage_workspace so that it accepted an optional title parameter, though this works only up to Plone 4.x; the script no longer exists in Plone 5.