Thank you for your effort.
However, I don't have D11. This issue was originally raised with the 2.1x, so I am unable to test it now.
A backport would be helpful if anyone can confirm that it works as expected.
Thank you, much appreciated. It now works as expected for the custom_field module as well.
You just saved my day!
You are right, it seems it works fine with version 2.0.8 and I can see tables from the second database, however unable to test it because of issue reported in #4.
Hello,
First of all thank you for your quick response. However I have red instructions before I installed module so not sure why you think, my table don't have any primary key. It does :
1.
2.First problem is that table with version 2.0.8 cannot be scanned if there is missing "database prefix" as follow:
3.So you have to add prefix - database, which was not really needed with version 2.0.5 but okey :
4.Now once i save it i will be forwarded to main page, but it says table is created with warning, but i an unable to see that table and remove it, hence rollback of database is needed or uninstall/install module again which means all previously created tables are gone (if you move from 2.0.5 to 2.0.8)
5.if I navigate to "All Views Custom Tables" tab as follow:
6. there is following error:
7.If I navigate to "Settings" tab there are a lot of errors:
However I am using Drupal 10.4.6 and Php 8.1.27. Do you think it could be php related ?
I cannot currently upgrade because of stakeholders.
Btw it does not work with decimal like "10.2" is that expected behavior or should I raise additional bug ?
hi,
I just tried
<div class="progress-circle">
<div class="progress-circle__wrapper">
<div class="progress-circle__value">10</div>
</div>
</div>
and it works as expected for me.
Thank you. Do you think it is possible that one day this feature will be avaiable or this module is build in a way that this feature wont work?
Thank you so much for your detailed step by step.
I am not using a view field view module, just simple twig:
{% set nidid = nid|render|striptags|spaceless %}
{{ drupal_view('view_name', 'embed_1',nidid) }}
However when I change "embed_1" to "block_1'" it works as expected.
So once again Thank you.
But can you be so kind and answer my questions?
I just tested with Views Vanilla JavaScript Tabs only for 2 views. Separetelly both views works fine, but if you try embed one view into another the second view will change"Views Vanilla JavaScript Tabs" into "href" only.
and if I render one view to antoher - tabs will be changed to href:
still the same issue. merge request did not fix it.
I see, also I have notice, that my web pages where "field group" is used is slower now. Does anyone experience the same issue after applied this patch?
for me patch #68 did not work for Date field and entity reference so I asked AI for a help and this part of code has been changed from patch #68
Original :
+ // Get the views ResultRow.
+ $results_row = $form['output'][0]['#view']->result[$row] ?? NULL;
+
+ // Find the entity we are updating from the ResultRow.
+ if ($results_row instanceof ResultRow) {
+ if (!empty($trigger['#relationship']) && $trigger['#relationship'] != 'none') {
+ $entity = $results_row->_relationship_entities[$trigger['#relationship']];
+ }
+ elseif (!empty($trigger['#ajax']['#relationship']) && $trigger['#relationship'] != 'none') {
+ $entity = $results_row->_relationship_entities[$trigger['#ajax']['#relationship']];
+ }
+ else {
+ $entity = $results_row->_entity;
+ }
+
+ // Reload the entity.
+ $entity_type = $entity->getEntityTypeId();
+ $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity->id());
+ }
+
+ // If the entity has the field - write the value.
+ if (isset($entity) && is_object($entity) && $entity->hasField($field)) {
+ if (in_array($value_type, ['target_id', 'date'])) {
+ $entity->set($field, [$value_type = $value]);
+ }
+ else {
+ $entity->set($field, $value);
+ }
+ $entity->save();
+ return ['#markup' => "Ok"];
+ }
and replaced with
// Get the views ResultRow.
$results_row = $form['output'][0]['#view']->result[$row] ?? NULL;
// Find the entity we are updating from the ResultRow.
if ($results_row instanceof ResultRow) {
if (
isset($trigger['#relationship']) &&
!empty($trigger['#relationship']) &&
$trigger['#relationship'] != 'none'
) {
$entity = $results_row->_relationship_entities[$trigger['#relationship']];
}
elseif (
isset($trigger['#ajax']['#relationship']) &&
!empty($trigger['#ajax']['#relationship']) &&
$trigger['#ajax']['#relationship'] != 'none'
) {
$entity = $results_row->_relationship_entities[$trigger['#ajax']['#relationship']];
}
else {
$entity = $results_row->_entity;
}
// Reload the entity.
if ($entity !== NULL && is_object($entity)) {
// Proceed as before
$entity_type = $entity->getEntityTypeId();
$entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity->id());
}
} else {
\Drupal::logger('views_entity_form_field')->error('No entity found for row @row and field @field', [
'@row' => $row,
'@field' => $field,
]);
return ['#markup' => "Entity not found."];
}
// If the entity has the field - write the value.
if (isset($entity) && is_object($entity) && $entity->hasField($field)) {
$field_type = $entity->getFieldDefinition($field)->getType();
if ($field_type === 'entity_reference') {
// Entity reference (user, taxonomy, node, etc.)
if (is_array($value) && isset($value['target_id'])) {
$entity->set($field, [ ['target_id' => $value['target_id']] ]);
}
elseif (is_numeric($value)) {
$entity->set($field, [ ['target_id' => $value] ]);
}
elseif (is_string($value) && preg_match('/\((\d+)\)$/', $value, $matches)) {
$entity->set($field, [ ['target_id' => $matches[1]] ]);
}
else {
\Drupal::logger('views_entity_form_field')->error('Could not extract target_id from value: @value', ['@value' => print_r($value, TRUE)]);
}
}
elseif ($field_type === 'datetime' || $field_type === 'timestamp') {
if (is_string($value)) {
$entity->set($field, ['value' => $value]);
}
elseif (is_array($value) && isset($value['date'])) {
$date = $value['date'];
$time = isset($value['time']) ? $value['time'] : '00:00:00';
$datetime = $date . 'T' . $time;
$entity->set($field, ['value' => $datetime]);
}
elseif (is_array($value) && isset($value['value'])) {
$entity->set($field, $value);
}
else {
\Drupal::logger('views_entity_form_field')->error('Unexpected date value: @value', ['@value' => print_r($value, TRUE)]);
}
}
else {
$entity->set($field, $value);
}
$entity->save();
return ['#markup' => "Ok"];
}
attached you can find the file. If anyone can check and create a patch i would be grateful.
EntityFormField.php_.txt →
This is really the first time it works for me as expected for all tested cases like "standard text, boolean, entity reference and Date field". I have tested it several times with a multiple nodes and all works finally as expected.
Well it seems this module is almost dead and there are like 70+ open issues with no admin activity and when there is anyone who can help and possible enhance this awesome module - you wont let him to help you?
Why?
Hi @pcate , When I try BUILD FORM > FORM FIELD: SET LABEL - it works fine for any field, so I guess this can be closed?
However this one does not work for a submit button so there is additional issue 3511126 ✨ ECA Form: Change button label Active created.
Hello,
Is there any update?
When I try BUILD FORM > FORM FIELD: SET LABEL - it works fine for any field, but not for a submit button so I guess this issue was created exactly for this.
It works finally.
It seems i need to use additional event "form submit" and now "FORM:Compare Triggered Submission" works.
I am lost :(...
1. Build Form (article)
2. Action FORM:ADD Submit button ie. Trigger name "abc" , label "ABC", type "Secondary"
When I navigate to article node I can see button there, if I click on it it will redirect me to "/admin/content"
How can I change that behavior so for example it will clone the current node, or display some message when I hit that button ? ...When I try to use additional action like "display message" or "Entity: Clone existing" it will clone the entity during the refresh the page no matter if I click on that submit button or not.
so what should be step 3 actually ? I believe I need to use that trigger name anywhere, but not sure where..
Thank you guys, it works as expected. So the solution is very simple here.
For others with a similar problem: There is no need to use Action(task) called "entity:load via reference"
, but for custom_field use just direct token instead.
My profile fields:
so I was able to use direct token in ECA :
CustomFIeld: Required role is <strong>[buildstart:field_custom_pm:pm:entity:field_type_of_user]</strong>and assigned user will be: [buildstart:field_custom_pm:pm:entity:field_user_information]
and this is expected result:
Such a simple solution and I have spent like 3 days :D
Thank you for your input, but unfortunately ,the same result, except instead of ref.number "3" it uses "username" when I try with "entity".
ECA Build form - Load via Reference (process_k086hog) for event eca.form.build: Field coaston does not exist for entity type node/project..\n\
Thank you, just a little hint is needed - should I start with "Build Form" or "After build form" when I need to achieve "cancel" button ?
First of all - My bad, I should mention that currently I am using Entity Extra field and would like to replace it and use only your "custom_field" module. That is the reason why I raised this issue.
Secondly. I am testing on clean drupal 10.5.1 latest version where currently only 2 contrib modules are installed 1.Custom_field and 2.ECA. I have also uninstalled already mentioned "Field Group" module.
I am quite surprised that you are not able to reproduce the issue because it is quite simple, but here you can find detailed step by step:
1. Create Content TYPE A (Project)
2. Create Content TYPE B (Project Inventory)
-on TYPE B - add field entity reference to Content type A
3.Create dummy Project (content type A)
4.Create dummy Inventory with ref to Project.
Create a View like "Project Inventories" of Type B.
-Add Relation ship - connect project with inventory (Ref to Project field)
-Add Title with relationship.
-Add Contextual filter - ID (with relationship and Provide default value : Content ID from URL)
Now you should be able to see view only for specific Project ID.
5- on Content TYPE A - add field > custom_field with subfield viewfield and use that currently created view (Project Inventories)
6. Now go to our first project edit it and assign that viewfield with that view
7.You should be able to see our view displayed correctly.
8.Now create new dummy project our viewfield and visit it.
9.You should be able to see at least label of our viewfield but also class in browser.
Of course in Manage display I can disable all labels so I have tried but still it tries to render anything:
With above steps this you should be able to simply reproduce the issue.
I have mentioned Entity Extra field because there was exactly the same problem and it was resolved. Now it won't display/render anything in browser!.
Another step is to install already mentioned Field group module, which uses tabs and if there is no any view rendered, the tab is hidden by default. In some cases our Projects don't have any Inventory at all so our customers would be confused what this tab means and why it is there displayed and empty. Thats why I would like to not see it if there no any inventory assigned to project.
Entity extra field basically does the same thing as your viewfield ,except it can render also blocks, but I don't use it for blocks, so I would love to uninstall it and use only your viewfield subfield as in my case it does the same.
Hope it makes sense now.
Thank you!
I tested it and it works as expected :
However the Display mode formatter it seems only works for the "default". When I change to table or flipped table it does not save it. {nothing in logs}. The same "issue" when I tried with Views - only the default formatter works as shown here: Formatter.mp4 →
Thank you.
i am in, but will be limited due to vacation time.
Hi
I think you can add Custom field → as an alternative module. With custom field you can add as many "reference subfields" as you like so you are not limited.
Kriss, simply use ECA → module - witht this one you can do anything you like and this is basiclly very simple like 20 seconds task there.
Settings for whether to show timezone in form?
I guess so.
Settings to make it required if a value is set?
Well maybe add ability in form display to add default value - like UTC preselected by default? And if no default value is configured - yes required field would do the trick.
Should it be permissioned? Example: If you as admin set a timezone value, should other user ALWAYS be allowed to override it to some other value?
Well we (PMs) have backups and of course there can be a mistake so any backup or "Regional Lead" should be able to change it if needed so at least "role" based would be nice.
Settings to filter the timezone options? Maybe you want to make it simple and just have a couple relevant timezones to select from?
That would be really nice feature as currently we work in severals countries only and do not need to see list options of all timezones. So sort of "multiselect list in form display mode" would be really helpfull so we can select like 20 to show for our PMS and if needed later we can add more in settings.
Assuming we should add multiple options here for output of which timezone to display the date in. Site timezone, user timezone, new timezone value on date field?
Views stuff may need to remain the same perhaps for now at least at least for sorting, not sure how multiple values in different timezones would work?
Well smart date works in similiar way, unable to display the date in both timezones at the same time but in views you can add the same field twice (multiple times) and for every field choose diferent timezone to display - site timezone, or or user timezone and of course that selected one and also there is option to display in UTC.
Hope it helps. Much apprciated your time and effort:)
My expectation was to have two fields:
1. A datetime field
2. A timezone selectioN
You would choose their timezone on save, and the actual date saved would be in their timezone, but the value shown to you would be in your timezone?
No, I want to see it always in their timezone because the change was made there, and it is their local time. I don’t care about my US time. For example, an engineer will call me to say the job is done at 9:00 PM local Berlin time, and I would like to add 9:00 PM to the system. However, currently, the system recalculates it to my profile’s timezone and stores it as 11:30 AM UTC, which is 1:30 PM in my timezone, not the reported 9:00 PM.
It would be nice to have a timezone selection that ignores my profile’s timezone. So, if I add 9:00 PM and select Berlin/Germany, it will store 7:00 PM UTC in the database.
You’re probably right—it’s better to create a new subfield type instead of modifying the default “date” type with a widget only.
Thank you for your information.
I have installed switch page theme → module for a temporary solution of my specific content type as it works fine with claro theme.
Ah I just realized I am using Cancel → button module. Once I disable it - it works as expected. So it is caused by this module. However once I disable ECA model it also works, so looks like ECA and Entity Form Cancel Button are not compatible in this case.
So not sure if anyone can help - and determine why ECA Entity Form Build Entity task has such "weird" impact.
Thank you, much appreciated.
Well, to implement ability to add "optional" timezone converter using timezones or using php
print_r(DateTimeZone::listIdentifiers());
would be really nice. The same as currently module smart_date → does.
so user can optionally select also timezone and it will be converted to UTC as always in database. That would be really nice feature and as you suggested if enginer is in Berlin, or in Paris, PM can select his timezone.
Thank you.
I have raised drupal core issue 🐛 View Mode renders Title Active
Thank you,
I have tested your code with a custom module and I have disabled "My eca model" and now when custom module force teaser or any other view mode (including the default one" i can see title twice. So it seems you were right it is not eca related.
Not sure what now:)
Hm...even I change from "teaser" to "default" view mode in "Entity:set view mode" it is the same.
Actually i wanted condition if customer is X then teaser and if negate condition use default.
-title is displayed in both cases.
But of course I have tested with a simple model where there is not any condition but if I choose "default" there is the same behaviour.
Thank you, your patch works as expected. No issue found. I think it is ready to be merged.
Actually #7 is my answer to your question jurgenhass.
If there is not any plan to provide a patch i think this topic can be closed as this workaround with Form:add grouping element is quite a good one.
Thank you.
Well, i currently cannot update php (8.1.26) to later version due to stakeholders so I was afraid to update to 3.1 if there is not any 8.2+ php requirement. But if not i will because some modules need higher version of php already.
But back to topic - i just wanted to provide workaround for others with the same problem that ECA can update custom_field and its subdields without loosing data.
You can create one standard field and use it for feeds cvs import and then with eca connect it with custom_field and replace values so in this case data wont be lost.
Example:
I do have csv with 2 columns and 1000 rows: first column : node_id
Second column : city
City is our custom_field:city but i cannot update it using feeds because the rest 10 subdields will be replacet with value null.
So i can create a standard field called "feedimport" and it can be a string one for example. In feeds maper i will use first column node_id and the second city as source but feedimport as my field.
Will import 1000 cities to my feedimport field
Now will create views and get all nodes which dont have feedsimport field blank so i will get exactly 1000nodes i need.
Now using eca i can loop the view and replace the value from its feedsimport field to custom_field:city and right after clear feedsimport field to null so it is blank and will be ready for next use.
This looks a bit complex, but it is no coding solution and one time configuration only because that feedsimport field you can reuse for any content type just update eca with the exact custom_field:subfield next time is needed.
So i can repeat the process for my other subfields if needed. But yeah if more then 2 fields need to be updated this is time consuming.
But i will give a try and try to update your code to see if it helps for my purpose.
What a pity.
For a select list with a several options is good workaround to use eca → module using Views as follow:
1.Create a standard boolean field called "feedsimport" to content type
2.Use feeds module and update to value 1 all content types which needs to be updated.
3.Create view and use filter to boolean 1 so only nodes which need to be updated are selected.
4.Create eca model > Use Loop of view with "Views: Execute query" task and "Set: Field value" of your custom field(subfield) like custom_field:status
with your prefered value like "Open" or "Closed"
This works fine for simple select list, but in my case like Location ,or city which is always different ECA won't help I guess :(
Thank you. Understood.
Does it mean that entity_reference does not work currently ? Because it always fails for me :(
Hi Ampsooner,
Sorry to add comment to already closed one, but struggling to add entity reference to taxonomy field I am using following code :
/**
* Adds the "categoryref'" column to the "Settings" field
*/
function custom_field_updates_update_9037(): void {
/** @var \Drupal\custom_field\CustomFieldUpdateManagerInterface $update_manager */
$update_manager = Drupal::service('custom_field.update_manager');
$update_manager->addColumn('node', 'field_settings', 'categoryref', 'entity_reference', ['target_type' => 'taxonomy_term']);
}
It always fail with the message :
custom_field_updates module
Update #9037
Failed: Drupal\Core\Field\FieldException: Field 'categoryref' references a target entity type '' which does not exist. in Drupal\custom_field\Plugin\CustomField\FieldType\EntityReference::schema() (line 40 of /modules/contrib/custom_field/src/Plugin/CustomField/FieldType/EntityReference.php).
Any help would be appreciated.
Hi killah89,
Use visible when bool field has value 1.
So unchecked or 0 will be hidden.
Or you can try option "empty", but above one works fine.
However this is different topic related to date field in modal dialog windows, so you should raise a new one if above wont work.
Yeah I did, it works for all types, except the date field.
Is there any update - i do like an idea to release a 2.0 branch.
Is anyone able to release a new version?
It works now..yupii.
Instead of field group i used ECA directly.
Form:add grouping element and I have added element name like "datex" , title and fields just field_date so I was able to use element name "datex" as my field name of Add state.
However as Title is required i was not happy with details wrapper so I added additional "form: add container element" and element name "datex" so now everything works as expected.
However I am not sure how this "form: add container element" works.
I think I do not need both forms at the same time but currently this is my workaround.
Do you think there can be any patch created which will add container to date fields by default so no need to do such "workarounds"?
thank you, it seems you are right.
I have also tested with custom_field → module and it does not hide the field by default when the widget is "Stacked" however when you change it to Flaxbox and use "fieldset" or "details" type of Wrapper it works.
So I wanted to replicate the same as you suggested with the date and for me the fastest way is to use field_group → module, so I added field group HTML element , with "div" element and added extra CSS class "datewrapper" and added CSS like
.datewrapper {
padding: 10px;
border: 1px solid #ccc;
background-color: #f9f9f9;
}
However I can still see the date field , of course the css is applied correctly, but still not working with visibility. I have tried also with fieldset type of field group with the same result :(
Any suggestion? Any advice would be greatly appreciated.
any update guys ?
Hi,
It seems the blocker has been resolved. Do yo have a plan to continue ?
This module looks like the one I was looking for.
Hi flocondetoile - do you have a plan to release drupal 11 version?
Any update?
Not sure why the issue was created twice.
Hi atomi, was your problem fixed? If not, provide more details or your model.
+1
Thank you, I started from the scratch and somehow it is working now with above Forms.
Thank you. I think this is exactly what I have done like 10times already but the problem is that in that case also the default save button is impacted and both save/submit and custom button redirects to same destination. But i only need the custom button to redirect there.
Button has "trigger name" so i wanted to try condition form:compare triggered submission but still does not work.
Hi yes please close this. ECA module replaces this whole module so i unistalled it already.
Are you able to create a new module for d10/d12 and maitain it?
Hi,
So once you click save button - nothing is saved?
Wau such a simple solution and I have spent hours with a complex one.
Much appreciated.Another module can be replaced with ECA now.
coaston → created an issue.
Hi @freelock, any progress? This sounds good.
You're right. In my local environment, I have about 10 different test sites, and this particular one is quite old, using an older Drupal 9 or 10 version. But if needed, I can recreate it, as it's very easy to set up.
I'm also impressed because I've been missing this feature for almost two years, and I have sites in production that couldn't be migrated from Drupal 9 to 10 because there's no stable release of the Business Rules module. So now we can finally migrate to Drupal 10.
For drupal 10/11 we can use ECA to achieve the same as described here 💬 Dependent fields with ECA Active .
Thank you.
Information for others who are facing the same problem as I am and want to replicate the 'dependent field': Here is the exact model that performs this function Eca dependent-field → , and we can finally remove the rules module and use only ECA.
Here you can find my video Eca Dependent. →
Note: who needs to use Taxonomy instead of select list, just use Options instead of "11:11: anything like "[tid]:[name] so "671:Admin change"
@jurgenhaas I believe this example can be added to eca library because i believe many users will find is useful and this feature prevented to get rid of rules as described here. →
Hi jurgenhaas,
Sorry, I somehow didn't notice that you had replied until just now.
I wanted to try, but not sure what I am doing wrong. I have used following example : Endpoint Test and i have updated Route Match to "entity.node.edit_form"
so now when I navigate to article node/x/edit I can see message like "You are visiting "[mynode:title]" so it works for my edit form, however as you suggested there should be ajax available now, so I wanted to select TAG and display the current value, however it does not work until I save the article.
In other words when I navigate node/x/edit and i would like to see message like "You are visiting "[mynode:title] and [mynode:field_tags]" but I can see message ""You are visiting "[mynode:title] and ..." which is fine because there is no any TAG added yet. Now I add tag with value 1 for example, but message still display "You are visiting "[mynode:title] and ..." and i need to save the node to see expected valu ["You are visiting "[mynode:title] and [mynode:field_tags]" so I cannot work dynamically with that value and possible update dependent field and ajax is not working in this case, or am I missing anything ?
thank you,
Will try this method, it sounds less complicated.
I guess this can be closed.
Thank you jurgen,
If you mean to create a content type in drupal with fields and use for example feeds module to load them - this would require additional step in between as vba cannot interact with drupal server directly to store for example json because of firewall, vpn and proxy in our case.
So we can use just mysql and using insert into table commands is quite difficult in drupal as it has many references and many tables as every field has 2x. This could be option but wanted to try any simplifier one thats why i wanted to use that views custom table one but did not expect that eca wont work with..