Problem/Motivation

Machine name validation for element fires each time there's no way to disable and prevent that

Proposed resolution

Allow to set #access or #disabled property to control that

Remaining tasks

Find a way to access the property and document that in render element doc block

User interface changes

API changes

Original report by @niko-

Hi

Today I found that ctools export drop previous cloned copy of any type of objects.

My enveronment is fresh D7 install with last versions of ctools and panels

Steps to reproduce.

1. Create flexible layout with name XXX
2. Clone it via UI
3. Clone it (Not "clone_of_XXX" instance but original) second time and change any thing in this copy but not the machine name (row, region ...)

Layout cloned on step 3 will overwrite layout cloned on step 2

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

niko-’s picture

Hm

My debug shows that reason of overriding is #machine_name core validator

it looks like now

  if ($element['#default_value'] !== $element['#value']) {
    $function = $element['#machine_name']['exists'];
    if ($function($element['#value'], $element, $form_state)) {
      form_error($element, t('The machine-readable name is already in use. It must be unique.'));
    }
  }

but if I do not touch machine_name but change human name, machine name will not change.
So #default_value == #value and uniq check will skip.

Same in Drupal 8 core.

niko-’s picture

I checked the #machine_name form element type
https://api.drupal.org/api/drupal/developer%21topics%21forms_api_referen...
and example in menu module.

As I understood, only if element disabled it must not be validate with callback specified in 'exists' elment key.

I think if user can change machine_name it must be validated

So in edit forms if this is regular edit without clone we must set

$form['machine_name']['#disabled'] = TRUE

In any clone like form we set

$form['machine_name']['#disabled'] = FALSE

or do not set $form['machine_name']['#disabled'] at all

patch attached

P.S.
If my hotfix is right then this is need to check core modules about this changes

niko-’s picture

Drupal 8 patch

niko-’s picture

Status: Active » Needs review

The last submitted patch, 2: machine_name-missing-validation-2347171-2.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: machine_name-missing-validation-2347171-3.patch, failed testing.

andypost’s picture

Project: Chaos Tool Suite (ctools) » Drupal core
Version: 7.x-1.4 » 8.0.x-dev
Component: Code » ajax system
andypost’s picture

Component: ajax system » plugin system
Status: Needs work » Needs review
FileSize
1.2 KB

This one should be fixed in core first.
Disabled (no access) machine name could not be changed

Status: Needs review » Needs work

The last submitted patch, 8: ams1.patch, failed testing.

andypost’s picture

Title: ctools export drop previous cloned copy » Make machine name validation configurable
Issue summary: View changes
andypost’s picture

Status: Needs work » Needs review
FileSize
1.2 KB

Status: Needs review » Needs work

The last submitted patch, 11: ams1.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce, +Bug Smash Initiative

Disabled elements aren't submitted by the browser - can we get some steps to reproduce this?

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Kristen Pol’s picture

Thanks for reporting this issue. We rely on issue reports like this one to resolve bugs and improve Drupal core.

As part of the Bug Smash Initiative, we are triaging issues that are marked "Postponed (maintainer needs more info)". This issue was marked "Postponed (maintainer needs more info)" 3 months ago with a request for steps to reproduce and there has been no activity since that time.

Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Information needed to continue work on this issue has not been supplied in the past 12 months. Therefor, closing this as explained in #26.