Comments

joachim’s picture

Status: Active » Needs review
StatusFileSize
new1.12 KB

This was surprisingly easy. Works fine, though throws up error messages because of #1661238: hook_field_is_empty() gets junk data.

Patch is on top of #1659584: support taxonomy term as inline entity, obviously ;)

pjcdawkins’s picture

I'd really like to see this working. I think it'd make IEF very useful (even for those who don't use Commerce).

Is there any way around the error messages?

bojanz’s picture

I suggest using the latest -dev of entityreference if you want terms with inline entity form.
Using taxonomy term reference fields gives you no benefits. So this issue is not even in my Top 100 priority wise.

joachim’s picture

> Using taxonomy term reference fields gives you no benefits

Indeed, but it would be nice for existing sites that already have their data in this field type. I do agree with your assessment of the priority though :)

nbchip’s picture

Except that using entityreference u dont actually classify node under term, so node is not shown in default term view page

bojanz’s picture

@nbchip
That has been fixed in Entityreference 7.x-1.x-dev as far as I know (might even be in the last release, haven't checked).

bojanz’s picture

Status: Needs review » Postponed

Postponed on #1661238: hook_field_is_empty() gets junk data, if someone provides a patch for that issue, I will commit this one.

vasike’s picture

Status: Postponed » Needs review
StatusFileSize
new5.7 KB

here is a new patch that should provide solution for Taxonomy Term Reference fields.

- reroll the previous patch
- add extra validation for this field type () (mister bojanz suggestion):
tha validation function adds dummy tid values for the form element to avoid taxonomy_field_is_empty() errors.
- new autocomplete function for the "Add existing term" autocomplete form.

imho this issue should be closed/solved (i want to make it major task instead of feature request, but i let mister bojanz to do it) for 2 main reasons:
- Drupal core reference field
- Drupal systems that are already built using this kind of reference and they want to adopt this widget.

p.s. : should we mark the other issue (#1661238: hook_field_is_empty() gets junk data) as duplicate of this?

vasike’s picture

StatusFileSize
new5.62 KB

update the patch: use "dummy" validation for both IEF widgets.

bojanz’s picture

Looks good!

We can't do $form_state['values'][$element['#field_name']] because the values might be nested further down. You need to do:
drupal_array_get_nested_value($form_state['values'], $element['#parents']) instead;

vasike’s picture

@bojanz : thank you Sir
here is the patch, drupal_array_get_nested_value()'s way.

vasike’s picture

new patch : remove a trailing whitespace.

vasike’s picture

Title: support taxonomy term ref field » Support Taxonomy term reference fields
Issue summary: View changes
StatusFileSize
new5.41 KB

patch re-rolled.

k.skarlatos’s picture

This patch works for me, but i have the following problem. Non admin users cannot add new taxonomy terms, when there are already existing terms on the term reference field, the create new term button does not show up, only the "add existing term" does. creating new terms works ok with another widget like autocomplete deluxe.

vasike’s picture

@k.skarlatos : i think this how it should be, it respects the permissions for taxonomies.
So please check your taxonomies permissions.

k.skarlatos’s picture

My permissions seem fine, they have edit and delete permission, plus an add taxonomy term permission via Taxonomy access fix

Weaver’s picture

It would appear that IEF doesnt currently integrate with Taxonomy Access Fix, if I can get some proof of concept code together is someone interested in looking at it?

Weaver’s picture

Updated to work with taxonomy access fix, works in my use case, code is long hand just to make it more readable, what would be needed to get this committed?

Weaver’s picture

Also it seems entity_access('delete', $controller->entityType(), $entity) for taxonomies is returning whether the user can delete the vocabulary not the term.

entity_metadata_taxonomy_access (the callback used by entity_access for types of taxonomy_term and taxonomy_vocabulary) is woefully incomplete, have raised an issue at entity API. (https://www.drupal.org/node/2323619)

As a workaround in the meantime you can add an extra check in function inline_entity_form_field_widget_form to test if the current entity is a taxonomy and if it is, if the user has access to edit terms in the entities vocab...

if (empty($entity_id) || $controller->getSetting('allow_existing')
|| entity_access('delete', $controller->entityType(), $entity) ||
($settings['entity_type'] == 'taxonomy_term' && (user_access("delete terms in $entity->vid") || user_access('administer taxonomy')))) {

Circa line 630, your mileage may vary...

joachim’s picture

I'm not sure it's feasible to support all the modules that fix/improve taxonomy permissions. As well as https://www.drupal.org/project/taxonomy_access_fix, there's https://www.drupal.org/project/vppr, and possibly others.

Support for non-core permissions can be figured out in a follow-up, at least.

Weaver’s picture

Hi Joachim, what would you need to get that patch committed? Or are you saying that you don't want to support contrib modules only core (I would understand if you had concerns about changes to taxonomy_access_fix breaking your module), it would be good to know wether we should just fork IEF or continue to try and get involved with supporting it.

joachim’s picture

I'm not saying IEF shouldn't support that. What I'm saying is that supporting contrib taxonomy permissions is not as straight-foward as it might seem, and this issue has been going for over a year, so it would be best to focus on getting core support in first, and then figure out contrib support in a follow-on, otherwise we risk this dragging on even longer. The perfect is the enemy of the good :)

Weaver’s picture

OK thanks for the quick response, you are making perfect sense.

I assume you want to stay with Entity API for testing permissions as you do now so the same code supports different entity types. If so, then I think I've got the core permissions issues covered with this one:

https://www.drupal.org/node/2323619#comment-9066891

Is there any way you can push that issue? Do you know any of the Entity API maintainers?

The way I see it, we get that committed, test and confirm IEF is then behaving as expected with available core permissions, then revisit the above patch to expand it to work with contrib modules.

chris matthews’s picture

The 4 year old patch in #18 to inline_entity_form.module applied cleanly to the latest inline_entity_form 7.x-1.x-dev and if still applicable needs review.

firewaller’s picture

+1

bluegeek9’s picture

Status: Needs review » Closed (outdated)

We appreciate your contributions to Inline Entity Form. Drupal 7 in End-of-Life. We encourage you to upgrade to a supported version of Drupal.

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.