- last update
over 1 year ago 44 pass, 12 fail - 🇮🇳India saurabh-2k17
The last submitted patch, 80: 2856720-support_for_inline_entity_form-80.patch, failed testing. View results →
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- Issue was unassigned.
- last update
over 1 year ago 130 pass - 🇬🇧United Kingdom welly
I don't know if it's related to the patch but I'm getting the following error when I applied it.
TypeError: Drupal\conditional_fields\ConditionalFieldsFormHelper::elementAddProperty(): Argument #1 ($element) must be of type array, null given, called in /var/www/html/web/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php on line 208 in Drupal\conditional_fields\ConditionalFieldsFormHelper->elementAddProperty() (line 888 of modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php).
- Status changed to Needs work
over 1 year ago 2:54pm 27 June 2023 Here's a re-roll of patch #83 for the latest 4.0.0-alpha5 release.
Just uploading another patch that fixes a part in afterbuild where it wasn't getting the right entity bundle.
Does this patch work for anybody out there? It's currently not working for us, and we're working on getting it to work. Just curious if there's anyone out there that this patch is working for.
- 🇨🇦Canada joelpittet Vancouver
Just for context on the above interdiff in #87.
- $bundle = $form['#bundle'] ?? FALSE; - $entity_type = $form['#entity_type'] ?? FALSE; + $ief_entity = $form["#entity"]; + $bundle = $ief_entity->bundle(); + $entity_type = $ief_entity->getEntityTypeId();
Our
$form['#bundle']
was null and thus FALSE. This is for a custom entity type. Grabbing it from the$form["#entity"]
gave it the right value (as is similar but not the same to the current code outside of IEF).We are playing with the idea of simplifying the code paths be removing:
- $form = &$form_state->getCompleteForm(); + $full_form = &$form_state->getCompleteForm();
And letting the $form variable be unchanged.
and
public function loadDependencies($entity_type, $bundle) { - static $dependency_helper; - if (!isset($dependency_helper[$entity_type][$bundle])) { - $dependency_helper[$entity_type][$bundle] = new DependencyHelper($entity_type, $bundle); + static $dependency_helpers; + $dependency_key = $entity_type . '.' . $bundle; + if (!isset($dependency_helpers[$dependency_key])) { + $dependency_helpers[$dependency_key] = new DependencyHelper($entity_type, $bundle); } - return $dependency_helper[$entity_type][$bundle]->getBundleDependencies(); + return $dependency_helpers[$dependency_key]->getBundleDependencies(); }
Looks to be unneeded since the reroll in #86.
This patch gets it working for us.
Inside the getState method of ConditionalFieldsFormHelper, when you use $form_state to grab the entity , it gives you the entity from the main form, rather than the entity inside the inline entity form (the entity being referenced). This patch fixes that.- last update
about 1 year ago 130 pass - last update
about 1 year ago 130 pass - Status changed to Needs review
about 1 year ago 8:12pm 7 November 2023 - last update
about 1 year ago 130 pass - last update
about 1 year ago 130 pass - Status changed to RTBC
12 months ago 9:21am 22 December 2023 - 🇮🇳India Megha_kundar
Working as expected
Thank you very much for patch !!
Hence moving to RTBC. - Status changed to Needs work
10 months ago 12:37pm 28 February 2024 - 🇬🇧United Kingdom very_random_man
This patch in #89 causes the following error when trying to use Config Split to edit a config split setting.
Error: Call to a member function bundle() on null in Drupal\conditional_fields\ConditionalFieldsElementAlterHelper->afterBuild() (line 64 of modules/contrib/conditional_fields/src/ConditionalFieldsElementAlterHelper.php).
Removing the patch allows it to work.
- 🇨🇦Canada joelpittet Vancouver
@very_random_man maybe you can provide more info? We use config_split also. What version and what config was being split? Maybe we can reproduce the error and fix it. Thabks
- 🇬🇧United Kingdom very_random_man
Apologies for the terse response. :-)
I'm not sure it's specific to the config. I get the error when just trying to edit the config split entity at /admin/config/development/configuration/config-split/[ id ]/edit
I'm using Config Split 1.9.0 on Drupal 10.2.1.
This is the complete backtrace:
Error: Call to a member function bundle() on null in Drupal\conditional_fields\ConditionalFieldsElementAlterHelper->afterBuild() (line 64 of modules/contrib/conditional_fields/src/ConditionalFieldsElementAlterHelper.php). conditional_fields_element_after_build(Array, Object) call_user_func_array('conditional_fields_element_after_build', Array) (Line: 1084) Drupal\Core\Form\FormBuilder->doBuildForm('config_split_edit_form', Array, Object) (Line: 1076) Drupal\Core\Form\FormBuilder->doBuildForm('config_split_edit_form', Array, Object) (Line: 1076) Drupal\Core\Form\FormBuilder->doBuildForm('config_split_edit_form', Array, Object) (Line: 1076) Drupal\Core\Form\FormBuilder->doBuildForm('config_split_edit_form', Array, Object) (Line: 579) Drupal\Core\Form\FormBuilder->processForm('config_split_edit_form', Array, Object) (Line: 325) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39) Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 32) Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Having now had a look in the code, it looks like the `findInlineEntityFormParentsForElement` method is getting confused and incorrectly identifying a checkbox element instead of an inline_entity_form on the basis that it is called 'inline_entity_form'. I would assume that this is because the config split form has a checkboxes for each module.
I think the solution would be to check to see if the parent IEF form is actually a form and not a form element as part of `findInlineEntityFormParentsForElement`, rather than just assuming that is only IEF forms are called 'inline_entity_form'.
Thanks for reporting this @very_random_man and thanks for that info. I think you're right, it does need a check to make sure it's an inline entity form. We've implemented this in this new patch.
- Status changed to RTBC
10 months ago 8:02am 2 March 2024 - last update
10 months ago 130 pass - 🇬🇧United Kingdom very_random_man
Nice one, thanks! That definitely does the job. :-)
- last update
10 months ago 130 pass - 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin
What a long issue and patch history! +1 for all the hardwork in here.
Review/Testing now for commit ...
- 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin
Proposed resolution
Inject information about the inner form's entity so that it can be detected when conditional_fields_element_after_build() runs for the outer form.
Seems still valid but the patch kindof changed over time(?), so we need to change the title accordingly before commiting this change, since the original title is too random to track down possible follow ups. Thoughts for a better title from the latest patch authors?
- 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin
Hm ... to speed things up here (this issue has run long enough) I take my own consideration into account. Especially because
When an inline entity form is used to create content, the conditional_field.js is not loaded and the conditional field rules do not run.
clearly states that IEF hasn't been supported yet before. And I do not see any documented support for IEF in this project before mentioned. I will set this issue to FR now.
But I see a lot of issues with the same scope not linked here yet, like:
#2193025: Inline Entity Form compatibility →
#1941814: Conditional Field doesn't validate my form with inline entity form →
#2188977: Inline Entity Form field cannot be dependent (error when used with IEF module) →
#3079723: Compatibility with Inline Entity Form →
#2892321: About using an inline Entity form with the [visible option] →Some of them I will surely close in favour of this one here.
- Status changed to Fixed
10 months ago 2:04pm 2 March 2024 - 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin
Addendum: Removed patch file accidently left in file root from latest commit. Too many terminals open today to clean up the issue queue...
Automatically closed - issue fixed for 2 weeks with no activity.