When creating a new node and selecting a term from HS the node is saved instantly.
I have a taxonomy vocabulary with Countries / Cities.

Upon selecting a parent term (country) i.e. Russia, it instantly shows me the Cities i.e. Moscow, St. Petersburg but the node itself is instantly saved. If i have any other fields that are compulsory, it will keep me on the editing page but pops up the warnings that i must complete the remaining fields. If i don't have any compulsory fields left to complete it will simply save the node and redirects me to the "view" page.

I don't know if this is a bug.

PS: Excuse my english

Comments

marcoscano’s picture

Priority: Normal » Major

+1. Same happening for me, whith the slight difference that if there are no mandatory fields it saves the node but keeps the form open. When I do complete all the fields and save, the node duplicates.

I'm using 7.x-3.x-dev.

Thanks

Joel MMCC’s picture

Same here. If the node is new (Add Content), a new copy of the node, complete with a new NID, is created for any click to create a new Taxonomy term at any level, including if I then [Cancel] out of that without actually creating a new Taxonomy term!

If Editing a node, it saves the node (pops up the green Content Saved banner right above the Hierarchical Select instead of its usual place), but does not create a duplicate (presumably unless Create New Revision is on), again on any attempt to add a new term.

This seriously messes up workflow. I don’t want to have to tell my clients any jump-through-hoops workarounds (e.g. save the new node without any Taxonomy, then go back and edit it to set Taxonomy terms to prevent duplicate nodes from being created en masse), especially since the whole point of this module is to make things easier.

Upgrading to “Critical” because this bug effectively makes Hierarchical Select worse than totally useless, being an actual danger to the integrity of site node data (e.g. a customer wants to try out a change to a node, intending to Preview it before Saving it, and also changes Taxonomy — oops! Create New Revision wasn’t on, so now the “trial” change is made permanent and not easily revertible!).

marcoscano’s picture

Priority: Major » Critical

Found these other issues that may be related to this one (or may even be the same issue):

http://drupal.org/node/1312762
http://drupal.org/node/1312286
http://drupal.org/node/1267768
http://drupal.org/node/1270306

marcoscano’s picture

@Athos and @Joel MMCC

are you using Administration Language module?

I discover this module was being a source of multiple problems, and after disabling it, this issue (and others) completely disappeared.

I hope this info can be of some help

Joel MMCC’s picture

@clanet, I don’t see any module by that name in my system. It was created on and exported from Drupal Gardens.

Here’s a “prettified” version of the output of DRUSH pm-list, showing every module we have:

pm-list
 Package             Name                                                        Type    Status         Version
 Acquia Ntwrk Cnctr  Acquia agent (acquia_agent)                                 Module  Disabled       7.x-1.3
 Acquia Ntwrk Cnctr  Acquia search (acquia_search)                               Module  Not installed  7.x-1.3
 Acquia Ntwrk Cnctr  Acquia site information (acquia_spi)                        Module  Disabled       7.x-1.3
 Administration      Administration Development tools (admin_devel)              Module  Enabled        7.x-3.0-rc1
 Administration      Administration menu (admin_menu)                            Module  Enabled        7.x-3.0-rc1
 Administration      Administration menu Toolbar style (admin_menu_toolbar)      Module  Enabled        7.x-3.0-rc1
 Administration      Administration views (admin_views)                          Module  Not installed  7.x-3.0-rc1
 CCK                 Content Templates (contemplate)                             Module  Enabled        7.x-1.0-rc3
 CCK                 Location CCK (location_cck)                                 Module  Enabled        7.x-3.x-dev
 Chaos tool suite    Bulk Export (bulk_export)                                   Module  Enabled        7.x-1.x-dev
 Chaos tool suite    Chaos tools (ctools)                                        Module  Enabled        7.x-1.x-dev
 Chaos tool suite    Chaos Tools (CTools) AJAX Example (ctools_ajax_sample)      Module  Not installed  7.x-1.x-dev
 Chaos tool suite    Chaos Tools (CTools) Plugin Example (ctools_plugin_example) Module  Not installed  7.x-1.x-dev
 Chaos tool suite    Custom content panes (ctools_custom_content)                Module  Enabled        7.x-1.x-dev
 Chaos tool suite    Custom rulesets (ctools_access_ruleset)                     Module  Enabled        7.x-1.x-dev
 Chaos tool suite    Page manager (page_manager)                                 Module  Enabled        7.x-1.x-dev
 Chaos tool suite    Stylizer (stylizer)                                         Module  Enabled        7.x-1.x-dev
 Chaos tool suite    Views content panes (views_content)                         Module  Enabled        7.x-1.x-dev
 Core                Aggregator (aggregator)                                     Module  Enabled        7.9
 Core                Block (block)                                               Module  Enabled        7.9
 Core                Blog (blog)                                                 Module  Enabled        7.9
 Core                Book (book)                                                 Module  Not installed  7.9
 Core                Color (color)                                               Module  Enabled        7.9
 Core                Comment (comment)                                           Module  Enabled        7.9
 Core                Contact (contact)                                           Module  Enabled        7.9
 Core                Content translation (translation)                           Module  Not installed  7.9
 Core                Contextual links (contextual)                               Module  Enabled        7.9
 Core                Dashboard (dashboard)                                       Module  Enabled        7.9
 Core                Database logging (dblog)                                    Module  Enabled        7.9
 Core                Field (field)                                               Module  Enabled        7.9
 Core                Field SQL storage (field_sql_storage)                       Module  Enabled        7.9        
 Core                Field UI (field_ui)                                         Module  Enabled        7.9
 Core                File (file)                                                 Module  Enabled        7.9
 Core                Filter (filter)                                             Module  Enabled        7.9
 Core                Forum (forum)                                               Module  Disabled       7.9
 Core                Help (help)                                                 Module  Enabled        7.9
 Core                Image (image)                                               Module  Enabled        7.9
 Core                List (list)                                                 Module  Enabled        7.9
 Core                Locale (locale)                                             Module  Not installed  7.9
 Core                Menu (menu)                                                 Module  Enabled        7.9
 Core                Node (node)                                                 Module  Enabled        7.9
 Core                Number (number)                                             Module  Enabled        7.9
 Core                OpenID (openid)                                             Module  Disabled       7.9
 Core                Options (options)                                           Module  Enabled        7.9
 Core                Overlay (overlay)                                           Module  Enabled        7.9
 Core                Path (path)                                                 Module  Enabled        7.9
 Core                PHP filter (php)                                            Module  Enabled        7.9
 Core                Poll (poll)                                                 Module  Enabled        7.9
 Core                RDF (rdf)                                                   Module  Enabled        7.9
 Core                Search (search)                                             Module  Enabled        7.9
 Core                Shortcut (shortcut)                                         Module  Enabled        7.9
 Core                Statistics (statistics)                                     Module  Enabled        7.9
 Core                Syslog (syslog)                                             Module  Enabled        7.9
 Core                System (system)                                             Module  Enabled        7.9
 Core                Taxonomy (taxonomy)                                         Module  Enabled        7.9
 Core                Testing (simpletest)                                        Module  Not installed  7.9
 Core                Text (text)                                                 Module  Enabled        7.9
 Core                Toolbar (toolbar)                                           Module  Disabled       7.9
 Core                Tracker (tracker)                                           Module  Not installed  7.9
 Core                Trigger (trigger)                                           Module  Enabled        7.9
 Core                Update manager (update)                                     Module  Enabled        7.9
 Core                User (user)                                                 Module  Enabled        7.9
 Date/Time           Calendar (calendar)                                         Module  Enabled        7.x-3.x-dev
 Date/Time           Calendar iCal (calendar_ical)                               Module  Enabled        7.x-3.x-dev
 Date/Time           Date (date)                                                 Module  Enabled        7.x-2.x-dev
 Date/Time           Date API (date_api)                                         Module  Enabled        7.x-2.x-dev
 Date/Time           Date Context (date_context)                                 Module  Not installed  7.x-2.x-dev
 Date/Time           Date Migration (date_migrate)                               Module  Not installed  7.x-2.x-dev
 Date/Time           Date Popup (date_popup)                                     Module  Enabled        7.x-2.x-dev
 Date/Time           Date Repeat API (date_repeat)                               Module  Enabled        7.x-2.x-dev
 Date/Time           Date Tools (date_tools)                                     Module  Enabled        7.x-2.x-dev
 Date/Time           Date Views (date_views)                                     Module  Enabled        7.x-2.x-dev
 Development         Devel (devel)                                               Module  Disabled       7.x-1.2
 Development         Devel generate (devel_generate)                             Module  Disabled       7.x-1.2
 Development         Devel node access (devel_node_access)                       Module  Enabled        7.x-1.2
 Development         Location Generate (location_generate)                       Module  Disabled       7.x-3.x-dev
 Drupal Gardens      Gardens features (gardens_features)                         Module  Enabled
 Drupal Gardens      Gardens feedback (feedback)                                 Module  Disabled
 Features            Date Migration Example (date_migrate_example)               Module  Not installed  7.x-2.x-dev
 Fields              Email (email)                                               Module  Enabled        7.x-1.0
 Fields              Link (link)                                                 Module  Enabled        7.x-1.0
 Form Elements       Hierarchical Select (hierarchical_select)                   Module  Enabled        7.x-3.0-alpha5
 Form Elements       Hierarchical Select Flat List (hs_flatlist)                 Module  Enabled        7.x-3.0-alpha5
 Form Elements       Hierarchical Select Menu (hs_menu)                          Module  Enabled        7.x-3.0-alpha5
 Form Elements       Hierarchical Select Small Hierarchy (hs_smallhierarchy)     Module  Enabled        7.x-3.0-alpha5
 Form Elements       Hierarchical Select Taxonomy (hs_taxonomy)                  Module  Enabled        7.x-3.0-alpha5
 Form Elements       Hierarchical Select Taxonomy Views (hs_taxonomy_views)      Module  Enabled        7.x-3.0-alpha5
 Location            GMap (gmap)                                                 Module  Enabled        7.x-1.x-dev
 Location            GMap Location (gmap_location)                               Module  Enabled        7.x-1.x-dev
 Location            GMap Macro Builder (gmap_macro_builder)                     Module  Enabled        7.x-1.x-dev
 Location            GMap Taxonomy Markers (gmap_taxonomy)                       Module  Enabled        7.x-1.x-dev
 Location            Location (location)                                         Module  Enabled        7.x-3.x-dev
 Location            Location Add Another (location_addanother)                  Module  Disabled       7.x-3.x-dev
 Location            Location Fax (location_fax)                                 Module  Enabled        7.x-3.x-dev
 Location            Location Phone (location_phone)                             Module  Enabled        7.x-3.x-dev
 Location            Location Search (location_search)                           Module  Enabled        7.x-3.x-dev
 Location            Location Taxonomy (location_taxonomy)                       Module  Enabled        7.x-3.x-dev
 Location            Node Locations (location_node)                              Module  Enabled        7.x-3.x-dev
 Location            User Locations (location_user)                              Module  Enabled        7.x-3.x-dev
 Login Toboggan      Email Login (logintoboggan_email_login)                     Module  Enabled
 Mail                Mailing List (mailing_list)                                 Module  Enabled        7.x-1.0-beta1
 Media               File entity (file_entity)                                   Module  Enabled        7.x-1.0-rc2
 Media               Media (media)                                               Module  Enabled        7.x-1.0-rc2
 Media               Media Browser Plus (media_browser_plus)                     Module  Enabled        7.x-1.0-beta3
 Media               Media Gallery (media_gallery)                               Module  Enabled        7.x-1.0-beta7
 Media               Media Internet Sources (media_internet)                     Module  Enabled        7.x-1.0-rc2
 Media               Media: YouTube (media_youtube)                              Module  Enabled        7.x-1.0-alpha5
 Media               Plupload integration module (plupload)                      Module  Enabled        7.x-1.0-beta3
 Organic groups      Profile2 group access (profile2_og_access)                  Module  Not installed  7.x-1.1
 Other               AddThis (addthis)                                           Module  Disabled       7.x-2.1-beta1
 Other               Advanced help (advanced_help)                               Module  Enabled        7.x-1.0-beta1
 Other               Advanced help example (help_example)                        Module  Not installed  7.x-1.0-beta1
 Other               Backports (backports)                                       Module  Enabled        7.x-1.0-alpha1
 Other               Block everything (block_everything)                         Module  Enabled
 Other               Comment notify (comment_notify)                             Module  Enabled        7.x-1.0-rc1
 Other               Contextual Flyout Links (contextual_flyout_links)           Module  Enabled
 Other               Entity API (entity)                                         Module  Enabled        7.x-1.0-beta11
 Other               Entity Reference (entityreference)                          Module  Enabled        7.x-1.0-beta1
 Other               Entity tokens (entity_token)                                Module  Enabled        7.x-1.0-beta11
 Other               Filter tips dialog (filter_tips_dialog)                     Module  Enabled        7.x-1.x-dev
 Other               Flexible blogs (flexible_blogs)                             Module  Disabled       7.x-1.0
 Other               Follow (follow)                                             Module  Enabled        7.x-1.0-alpha1
 Other               Font management (font_management)                           Module  Enabled
 Other               Form builder (form_builder)                                 Module  Disabled       7.x-1.x-dev
 Other               Form builder examples (form_builder_examples)               Module  Not installed  7.x-1.x-dev
 Other               Form builder Node UI (form_builder_node)                    Module  Disabled       7.x-1.x-dev
 Other               Form builder Webform UI (form_builder_webform)              Module  Disabled       7.x-1.x-dev
 Other               HTML Purifier (htmlpurifier)                                Module  Enabled        7.x-2.x-dev
 Other               Libraries (libraries)                                       Module  Enabled        7.x-1.0
 Other               Mollom (mollom)                                             Module  Disabled       7.x-1.1
 Other               Multiple forms (multiform)                                  Module  Enabled        7.x-1.0-beta2
 Other               Options element (options_element)                           Module  Disabled       7.x-1.4
 Other               Pathauto (pathauto)                                         Module  Enabled        7.x-1.0-rc2
 Other               Pathauto Live Preview (pathauto_live_preview)               Module  Enabled
 Other               Profile2 (profile2)                                         Module  Disabled       7.x-1.1
 Other               Profile2 pages (profile2_page)                              Module  Disabled       7.x-1.1
 Other               Redirect (redirect)                                         Module  Enabled        7.x-1.0-beta3
 Other               Rotating banner (rotating_banner)                           Module  Enabled        7.x-1.x-dev
 Other               Save Draft (save_draft)                                     Module  Enabled        7.x-1.4
 Other               Simple Query Builder for SimpleViews (sqbs)                 Module  Enabled
 Other               SimpleViews (simpleviews)                                   Module  Enabled
 Other               Simplified menu administration (simplified_menu_admin)      Module  Enabled        7.x-1.0-beta2
 Other               Simplified modules (simplified_modules)                     Module  Disabled       7.x-1.0-beta1
 Other               Site Verification (site_verify)                             Module  Disabled       7.x-1.0
 Other               Token (token)                                               Module  Enabled        7.x-1.0-beta7
 Other               Unified SEO UI (seo_ui)                                     Module  Enabled
 Other               UX Elements (ux_elements)                                   Module  Disabled       7.x-1.0-beta1
 Panels              Mini panels (panels_mini)                                   Module  Enabled        7.x-3.x-dev
 Panels              Panel nodes (panels_node)                                   Module  Enabled        7.x-3.x-dev
 Panels              Panels (panels)                                             Module  Enabled        7.x-3.x-dev
 Panels              Panels In-Place Editor (panels_ipe)                         Module  Enabled        7.x-3.x-dev
 Statistics          Google Analytics (googleanalytics)                          Module  Disabled       7.x-1.2
 Styles              File Styles (file_styles)                                   Module  Enabled        7.x-2.0-alpha8
 Styles              Styles (styles)                                             Module  Enabled        7.x-2.0-alpha8
 Styles              Styles UI (styles_ui)                                       Module  Enabled        7.x-2.0-alpha8
 User interface      Dialog API (dialog)                                         Module  Enabled        7.x-1.x-dev
 User interface      Dialog Comment (dialog_comment)                             Module  Enabled        7.x-1.x-dev
 User interface      Dialog contextual Links (dialog_contextual)                 Module  Enabled        7.x-1.x-dev
 User interface      Dialog Example (dialog_example)                             Module  Not installed  7.x-1.x-dev
 User interface      Dialog User (dialog_user)                                   Module  Enabled        7.x-1.x-dev
 User interface      External Links (extlink)                                    Module  Enabled        7.x-1.12
 User interface      Superfish (superfish)                                       Module  Enabled        7.x-1.8
 User interface      Typekit (typekit)                                           Module  Disabled       7.x-1.0-beta1
 User interface      Wysiwyg (wysiwyg)                                           Module  Enabled        7.x-2.1
 Views               Views (views)                                               Module  Enabled        7.x-3.x-dev
 Views               Views UI (views_ui)                                         Module  Enabled        7.x-3.x-dev
 Voting              Fivestar (fivestar)                                         Module  Disabled       7.x-2.0-alpha1
 Voting              Voting API (votingapi)                                      Module  Enabled        7.x-2.4
 Webform             Webform (webform)                                           Module  Disabled       7.x-3.13
 Webform             Webforms (webform_alt_ui)                                   Module  Disabled       7.x-1.x-dev
 XML sitemap         XML sitemap (xmlsitemap)                                    Module  Disabled       7.x-2.0-beta3
 XML sitemap         XML sitemap custom (xmlsitemap_custom)                      Module  Disabled       7.x-2.0-beta3
 XML sitemap         XML sitemap engines (xmlsitemap_engines)                    Module  Disabled       7.x-2.0-beta3
 XML sitemap         XML sitemap internationalization (xmlsitemap_i18n)          Module  Not installed  7.x-2.0-beta3
 XML sitemap         XML sitemap menu (xmlsitemap_menu)                          Module  Disabled       7.x-2.0-beta3
 XML sitemap         XML sitemap node (xmlsitemap_node)                          Module  Disabled       7.x-2.0-beta3
 XML sitemap         XML sitemap taxonomy (xmlsitemap_taxonomy)                  Module  Disabled       7.x-2.0-beta3
 XML sitemap         XML sitemap user (xmlsitemap_user)                          Module  Not installed  7.x-2.0-beta3
 Core                Bartik (bartik)                                             Theme   Disabled       7.9
 Core                Blossom (blossom)                                           Theme   Enabled        7.9
 Core                Garland (garland)                                           Theme   Disabled       7.9
 Core                Seven (seven)                                               Theme   Disabled       7.9
 Core                Stark (stark)                                               Theme   Disabled       7.9
 Other               My theme (acq_my_theme)                                     Theme   Disabled       1.20
 Other               SBSC Carbon (acq_sbsc_carbon)                               Theme   Enabled        1.21

All are the absolute latest recommended (for most) or .dev (for Calendar, CTools, Date, and Views) versions except that Views has not yet been updated to the 31-Oct-2011 .dev yet, since the MD5 checksum on it mismatched (see my Issue there).

Edited only to “prettify” the Drush pm-list output above.

Athos’s picture

Hi,

@clanet: No i don't use this specific module.

What i have noticed is that this issue occurs ONLY when i am logged in as an authenticated member.
When i am logged in as an administrator the problem described above DOES NOT happen.

It would be extremely complicating (at least to me) to find out if this issue is caused by another installed module. I 've compared the modules @Joel MMCC has installed with the ones i have and 70% are the same so...where do i begin?

regards
Athos

henrijs.seso’s picture

I have a theory on why this happens, just theory yet. So ajax is returning [...] correct form_id.

Update: Theory is that hierarchical_select_ajax() is inspired by file_ajax_upload() which says "As long as the form processing is properly encapsulated in the widget element...". And in case of file_ajax_upload(), it is well encapsuled in widget element and operates on sub-form for that widget. On the other hand hierarchical_select_ajax() is operating on full node form and when saving "Create new item form", submit button processes and submits whole node, not just widget. We need to investigate little more of how file.module does it :)

henrijs.seso’s picture

Title: HS saves node automatically. » Whole node form is saved instead of widget form, possible data loss
Version: 7.x-3.0-alpha5 » 7.x-3.x-dev
danielphenry’s picture

I'm also seeing this issue when creating new taxonomy terms on a new node. I do not have a file upload in the form in this case. Because of this it is creating duplicates of each node. Makes the module almost unusable.

snyderp’s picture

Here is a temporary fix. Implement hook_node_validate, which fires after all other form validation happens (including after the taxonomy fields are saved / processed)

In the hook, check to see if we're in an AJAX callaback initiated from the hierarchical_select module, and if so, silently set the node submission to fail (ie mark the form as invalid).

Haven't tested extensively, but is working for me and seems like it should generally work.

Here is a copy-paste snippet, if anyone is interested:

/**
 * Implements hook_node_validate().
 * @see http://api.drupal.org/api/drupal/modules--node--node.api.php/function/hook_node_validate/7
 */
function <your-module-name>_node_validate($node, $form, &$form_state) {

  // In general, don't save any nodes when the form submission is coming
  // from an hierarchical_select callback, since this will result in
  // duplicate copies of the same node being saved
  if (arg(0) == 'hierarchical_select_ajax') {

    form_set_error('');
  }
}

Hope that helps!

Athos’s picture

If i understand correctly we just need to paste the above somewhere? if yes then where?

Thanks
Athos

danielphenry’s picture

snyderp's workaround http://drupal.org/node/1293166#comment-5237076 (#10 above) seems to work for me.

The error here is that ajax_get_form on line 294 hierarchical_select.module is returning the whole node form. I think this means the ajax is modifying the existing node form instead of embedding a separate form to add a new term. I'm not really experienced with ajax/javascript so I'm not sure exactly how to fix this one. But the real solution would be to embed a separate form for creating a new term instead of modifying the existing form.

This workaround will do for now but in the mean time this needs to be addressed as the critical priority it is despite the workaround.

Athos,

Instead of using hook_node_validate (which requires you to create the node type in the same module) I just used a form alter and added a new validate handler.

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == '{node_type}_node_form') {
    $form['#validate'][] = 'my_module_hierarchy_validate';
  }
}

/**
 * Override the node edit form to not allow submission on hierarchical submit.
 *
 * This is a hack to get hierarchical select to not duplicate new nodes being
 * created. It may become unneccesary pending: http://drupal.org/node/1293166.
 */
function my_module_hierarchy_validate($form, $form_state) {

  if (arg(0) == 'hierarchical_select_ajax') {
    form_set_error('');
  }
}

You can past this into any custom module. Make sure to replace all occurances of "my_module" with the module name and "{node_type}" with the machine readable name of the node type you have the hierarchy form attached to.

snyderp’s picture

Just a quick clarification to danielson317's comment above, the hook_node_validate method does not require that the node content type be defined in the module. I'm sure :-)

But, both of these solutions have the exact same effect and use the same strategy.

Anonymous’s picture

Yeah, this prevents me from saving nodes completely, because of

The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.

...am using the admin language module.

-EDIT- that is the culprit: just dont use the admin language module

lindsayo’s picture

I'm also having this problem on 6.x-3.7.
It seems like #14 is suggesting that there's another module interfering? I don't have the admin language module on my site. Not sure what else to suspect, but I'll comb through and start disabling things to check.

EDIT - Looks like this was the Ajax module. Disabled, drush cc all, tested the node/add with multiple terms from HS, and works fine (got one node, not several).

MrPhilbert’s picture

Can you please be more specific. What is added? What is replaced? What line/s?

Or, could you upload the new file with corrections?

Joel MMCC’s picture

@morningtime #14:

Yeah, this prevents me from saving nodes completely, because of
The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.
...am using the admin language module.

-EDIT- that is the culprit: just don’t use the admin language module

No, that isn’t the culprit. I’ve never used that module (see my module list above), and I have the same issue.

Athos’s picture

:)...i am lost!!!

What do i have to do to fix this issue? i tried adding and deleting stuff from hiearchical.module (i am surprised it is still functioning) with no luck. I am not a programmer so if someone can explain in steps what we have to in order to correct this until next update would be great.

MrPhilbert’s picture

I just figured it out.

The error is in "live preview". There is a javascript file called common_config.js. Part of it is designed to show your selections.

If you look at line #113 (.filter(':not(.create-new-item-input):not(.create-new-item-create):not(.create-new-item-cancel)')), you'll see that it will delay the input until node save.

If you write any javascript, you'll know that the quotes will prevent this from parsing.

Just delete the single quotes and it will work or paste this in its place:

.filter(:not(.create-new-item-input):not(.create-new-item-create):not(.create-new-item-cancel))

Note: If your field is required, you'll still see required field warnings but this won't effect anything. I am working on an if statement to add to fix this.

Please let me know if this works.

Philbert

Athos’s picture

@MrPhilbert,

Hi,
Unfortunately your fix doesnt work on my site.
Please confirm that the file you are talking about is the common_config_form.js and NOT the common_config.js and it is located in sites/all/modules/hierarchical_select/includes

Thanks
Athos

MrPhilbert’s picture

Afraid you're right. I added existing terms. It also seems that this module has now been abandoned.
Wim Leers is now working for Facebook and has not posted anything on Drupal.org since September (as far as I can tell).

Unless someone (with a lot more expertise than I) can take over this module, it will not look good for Drupal and the open source community.

I really like Drupal but when things like this and the token problems et. al. happen, it makes me worry about the future of Drupal.

Athos’s picture

Yes this is unfortunate. (unfortunate for the project and not for Wim Leers whom I wish the very best). Perhaps we can somehow donate a little bit as an incentive to get this project moving forward?!
I believe that HS is one of the most important modules when creating forms.

MrPhilbert’s picture

I agree and also wish him the best.

I believe that Facebook pays very well and also keeps their people very busy.

At one point, he was working on a re-write of this as a 4.x release. Maybe someone would like to contact him and see if he is making any progress?

Drupa1ish’s picture

#10 works fine... Relax!

ahwebd’s picture

here's a custom module that solves this issue (using #10) and other HS issues (see http://drupal.org/node/1389740):

http://drupal.org/sandbox/ahwebd/1389734

adam_b’s picture

@ahwebd: any chance you could extract your sandbox module and post it here for testing? not all of us have access to git

guypaddock’s picture

Status: Active » Needs review
StatusFileSize
new4.89 KB

I spent some time debugging this issue and comparing how HS works compared with the File module.

The actual cause is not what @mansspams or @danielson317 theorized about there needing to be a sub-form. I checked and it doesn't look like file fields use any kind of sub-form to do processing; they're just vanilla form widgets / form elements.

Instead, it's actually the fact that FAPI can't determine what button was actually clicked when processing the form, so it assumes it was the "Save" button. You can see this behavior in includes/form.inc on line 1856.

The real hint here is that the other callbacks HS uses, such as the one that triggers the "add new item" form to be rendered in the first place or the callback once a user has chosen an item, do not cause the form to validate. Only the "Create" and "Cancel" buttons cause a problem. The process callback only places those buttons in the form array when the HS widget is in "creating new term" mode, and the process callback is fired BEFORE the FAPI evaluates what button was clicked, so they're not available for form processing.

The File module gets around this by always putting the upload controls / buttons in the form, even when the form is not in a state where uploads are accepted, and then enabling or disabling access to the controls in a "pre_render" callback. That didn't work here, so I used an "after_build" callback which seems to have done the trick.

I also noticed that the D7 AJAX API seems to handle some of these issues. Perhaps if HS was ported to use the built-in AJAX callbacks from D7, this problem might not need special handling. I'm not sure; I'm not up-to-speed yet on it. For now, I've just added a "TODO" comment inside _hs_process_render_create_new_item() to this effect. Hopefully, someone with more D7 AJAX callback experience can look at this.

The patch for this is attached. Please review.

guypaddock’s picture

Status: Needs review » Needs work

Setting this back to NW since it looks like this patch breaks the dropbox. With it applied, when you go back and edit a node that has existing terms selected in the dropbox, if you cancel the term add, the dropbox is cleared.

sixelats’s picture

Patch #27 works well when e.g. Title field is required but gives me the "field is required" error when the HS fields are required.

d.novikov’s picture

kartagis’s picture

#10 works for me smoothly.

wim leers’s picture

Component: Code - Content Taxonomy » Code

This is not specific to Taxonomy.

@GuyPaddock: any progress regarding #28?

johankasperi’s picture

#10 did it for me. Thanks!

betawavetom’s picture

I've found another solution that is working for me.

Here's how I did it:
1) created my own custom module
2) first identified my form ID (using the helpful info on drupal.org/node/651106)
3) implemented the code found on www.elvisblogs.org/drupal/solved-how-bypass-nodevalidate-hookformalter
Code looks like this:

function my_custom_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'name-or-id-of-your-form') {
    $form['changed']['#default_value'] = time()<strong> + 300; // gives the user 5 minutes to modify this form</strong>
  }
}

Now when I add a term and the form submits the whole node, there is a 5 minute time delay for when the user can save the form. It's an alternative way to deal with it (and certainly not perfect ~ but it works.)

I don't know if this would create issues elsewhere though.
What do you think?

PS: Hey Wim Leers, I think you've created about the only multiselect solution that feels and looks good. I wish I won the lottery to share with you. :)

David_Rothstein’s picture

I ran into a bug with the above patch when used inside the Panels IPE (and specifically when used with the Ctools modal dialog). The issue is that the "Cancel" button added by Ctools inside the form wizard wasn't working correctly. After some debugging I found this was due to the form API getting confused between the form's main "Cancel" button and the one added here, and not knowing which was clicked.

Since "Cancel" is a pretty common button name, I think if this patch is going to add it to a whole bunch of forms like that it would make sense to give it a different machine name other than the standard 'op' which Drupal normally uses.

I don't have time right now to roll this into the above patch directly, but the code for it looks something like below (applied on top of the patch in #27):

--- a/hierarchical_select.module
+++ b/hierarchical_select.module
@@ -596,6 +596,11 @@ function _hs_process_render_create_new_item($element, $hierarchy) {
 
   $element['hierarchical_select']['create_new_item']['cancel'] = array(
     '#type'                        => 'button',
+    // Since "Cancel" is a common button value, we set the name property to
+    // something Drupal doesn't normally use, to prevent the form API from
+    // confusing this with other buttons on the form and choosing the wrong
+    // triggering element when the form is submitted.
+    '#name' => 'hs_select_cancel',
     '#value'                    => t('Cancel'),
     '#attributes'                    => array('class' => array('create-new-item-cancel')),
     
jramby’s picture

Hi,

I have problem applying the patch #27... I've tried it on both stable and dev version of hierarchical_select.

jramby’s picture

Hi,

I have problem applying the patch #27... I've tried it on both 7.x-3.0-alpha5 and 7.x-3.x-dev version of hierarchical_select.

Thx

molnitza’s picture

The patch works without problems with 7.x-3.0-alpha5+9-dev.

oostie’s picture

Status: Needs work » Needs review
StatusFileSize
new5.07 KB

Rerolled patch @ #27 against DEV and added Davids recommendations @ #35.

jibize’s picture

The patch from #39 works only when the "Create" button is clicked for me, I still get the "... field is required." error when the Cancel button is clicked.

cyberranger’s picture

Version: 7.x-3.x-dev » 7.x-3.0-alpha5

The patch in #39 fixes the duplicate saving of the node when a new term is saved. However, if cancel is selected instead, the whole node is saved resulting in a duplicate when the node is saved.

cyberranger’s picture

#12 solved the issue for me.

wolvern’s picture

None of the above patches worked for me, but the solution from http://drupal.org/node/1389740 did the job perfectly

dgtlmoon’s picture

My two cents: HS is still submitting the node in ' drupal_process_form($form['#form_id'], $form, $form_state);' when you are selecting Create/Update/Cancel operations when managing a new term, so there for the form status has been changed..

  // Process user input. $form and $form_state are modified in the process.
  drupal_process_form($form['#form_id'], $form, $form_state);

which causes the message 'The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.'

dgtlmoon’s picture

Version: 7.x-3.0-alpha5 » 7.x-3.x-dev
dgtlmoon’s picture

Status: Needs review » Needs work
dgtlmoon’s picture

another option is to use 'shs' module with https://drupal.org/node/1893188

Strycker’s picture

#43 - this thing fix problem perfectly. Thanks for that!

vegardjo’s picture

Version: 7.x-3.x-dev » 7.x-3.0-alpha6
Issue summary: View changes

Just used a few hours here, what I found out: both solution #10 and #43 works fine for me for 3.0-alpha5, but none on alpha6. I downgraded and all is fine.

vegardjo’s picture

Version: 7.x-3.0-alpha6 » 7.x-3.x-dev

..sorry, correct is: workes on dev and alpha5, not alpha6 for me. Solution from #43 works better that #10

dags’s picture

#39 works for me. I think this is a good approach because it makes better use of the Form API (ie. it uses #limit_validation_errors).

jantoine’s picture

After applying the patch in #39, I was getting a "Received an invalid response from the server." error when clicking on the 'Cancel' button. Reverting the addition inspired by #35 resolved the error. This, however, resulted in the dropbox clearing behavior as described in #28. Changing the 'Cancel' button #type from 'button' to 'submit' resolved the dropbox being cleared issue. This change has also resolved:

  • other field errors being displayed as described in #40
  • duplicate content as described in #41
  • 'The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.' error as described in #44

In addition to changing the 'Cancel' button #type from 'button' to 'submit', the attached patch also addresses some coding standards issues and has been re-rolled against dev.

azinck’s picture

I haven't had time to read through all the comments or related issues here. It seems clear to me that the ajax implementation in Hierarchical Select leaves a lot to be desired. It really needs to be refactored to pass in a specific _triggering_element value.

In our case, we're seeing a problem because we're using Admin Language and the default front-end language is Spanish while the default back-end language is English. So the node edit form is built in English when on node/*/edit, but the ajax requests hit the hierarchical_select_ajax path which is not considered an admin path. So on submission form builder rebuilds the form in Spanish. Thus the submitted form has different values as compared to the rebuilt form for any elements that have had their values translated. This causes the code in _form_button_was_clicked() to not be able to determine which form element made the submission.

So we're seeing a bug merely because the word "Update" was translated on our site.

For our use-case the Hierarchical Select widget is never going to be used on any non-admin pages so our band-aid fix is to use hook_admin_paths_alter() to mark hierarchical_select_ajax as an admin path to ensure it always gets built in the same language as the submitted form was built in.

  • stefan.r committed 95a790a on 7.x-3.x authored by jantoine
    Issue #1293166 by Athos, GuyPaddock, Oostie, jantoine: Whole node form...
eric.chenchao’s picture

The patch in #52 works! So far so good. Thanks @jantoine

andrewmacpherson’s picture

Can the maintainer clarify the current status of this?
The commit in #54 was released in 7.x-3.0-alpha8, but the issue still says 'needs review'

stefan.r’s picture

This patch is not in alpha8 yet, it will be in alpha9 though. For now, I committed this even if it's not the nicest possible solution.

stefan.r’s picture

Status: Needs review » Active
pianomansam’s picture

Version: 7.x-3.x-dev » 7.x-3.0-alpha9
Status: Active » Fixed

Apparently this was fixed in 7.x-3.0-alpha9 but not updated to reflect that.

pianomansam’s picture

Status: Fixed » Closed (fixed)
heddn’s picture