Comments

roysegall’s picture

StatusFileSize
new5.17 KB

I made two fixes for the patch:
1. Remove the question mark from the end of each line.
2. Create a hook_update_7002 and put the the creation of the variables instead in hook_update_7001.

amitaibu’s picture

Status: Needs review » Needs work
+++ b/tests/title.testundefined
@@ -146,4 +146,28 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
+  function testAutomatedFieldAttachement() {

Test should check API.

+++ b/title.admin.incundefined
@@ -74,3 +74,25 @@ function title_field_replacement_form_submit($form, &$form_state) {
+      '#title' => t('Auto attach @replacement-name for the @entity-name entity', array(
+        '@entity-name' => $entity['label'],
+        '@replacement-name' => $entity['field replacement'][$entity['entity keys']['label']]['field']['field_name'],

Lets use a $params variable, and change @replcaement-name to @field-name

+++ b/title.installundefined
@@ -16,12 +16,35 @@ function _title_install_set_weight($weight) {
+function _title_install_variables_handle($op) {

Remove everything in the install file -- we don't need to the set the variable there.

+++ b/title.moduleundefined
@@ -552,6 +552,15 @@ function title_menu() {
+    'title' => 'Automated field attachment',

Maybe batter "Settings for the Title module"

+++ b/title.moduleundefined
@@ -552,6 +552,15 @@ function title_menu() {
+    'description' => 'Define which entity will get a title_field for each bundle creation.',

title_field => Title field.

+++ b/title.moduleundefined
@@ -747,3 +756,27 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+  title_field_replacement_batch_set($entity_type, $bundle, $entity_label);

Not needed.

roysegall’s picture

Status: Needs work » Needs review
StatusFileSize
new3.22 KB

Apply fixes.

amitaibu’s picture

Status: Needs review » Needs work
+++ b/title.admin.inc
@@ -74,3 +74,27 @@ function title_field_replacement_form_submit($form, &$form_state) {
+      '#type' => 'checkbox',

Lets change this to a select list.

+++ b/title.module
@@ -747,3 +756,28 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+ * Attach title_field automatically to the new bundle if the admin choosed it.

title_field => "Title field".

Remove "if the admin ..."

+++ b/title.module
@@ -747,3 +756,28 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+  drupal_set_message(t('The field @field-name was attached automaticly to the @entity-name.', $params));

Lets add also the bundle name to the message.

roysegall’s picture

StatusFileSize
new3.71 KB

Apply the fixes and i add one more thing: If we have a title_field attached, then we don't need to attach it again.

roysegall’s picture

Status: Needs work » Needs review

Change status.

Status: Needs review » Needs work

The last submitted patch, auto-attach-title-field-1704536-5.patch, failed testing.

amitaibu’s picture

+++ b/title.admin.inc
@@ -74,3 +74,32 @@ function title_field_replacement_form_submit($form, &$form_state) {
+    '#title' => t('Auto attach field title for: '),

Remove :

+++ b/title.admin.inc
@@ -74,3 +74,32 @@ function title_field_replacement_form_submit($form, &$form_state) {
+    '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),

Description doesn't make sense. "Enable to auto-attach a title field when a bundle is created in this entity-type."

+++ b/title.module
@@ -552,6 +552,15 @@ function title_menu() {
+    'description' => 'Settings for the title module.',

title => Title

+++ b/title.module
@@ -747,3 +756,39 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+  $variable_name = 'title_auto_attach_' . $entity_type;

If we are using it only once, we can remove this variable.

+++ b/title.module
@@ -747,3 +756,39 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+  // Don't continue if "Title field" is alredy exists.

is already => already

+++ b/title.module
@@ -747,3 +756,39 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+  drupal_set_message(t('The field @field-name was attached automaticly to the @entity-name.', $params));

* automaticly => automatically
* @bundle-name is still missing.

Also, seems tests are failing.

roysegall’s picture

StatusFileSize
new3.74 KB
roysegall’s picture

Status: Needs work » Needs review

Change status.

roysegall’s picture

StatusFileSize
new3.74 KB

Typo.

amitaibu’s picture

Status: Needs review » Needs work
+++ b/tests/title.test
@@ -146,4 +146,22 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
+    $instacnes = field_info_instances('node', 'foo');

Typo in $instacnes.
Anyway we don't need it, we can just assert field_info_instance()

roysegall’s picture

Status: Needs work » Needs review
StatusFileSize
new3.58 KB

I think this is it.

amitaibu’s picture

Patch improves settings page options.

amitaibu’s picture

Issue summary: View changes

Updated issue summary.

amitaibu’s picture

Issue summary: View changes

Updated issue summary.

amitaibu’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.32 KB

Fixed another typo, and updated Issue summary.
Seems RTBC to me (my patches only fixes minor typos).

plach’s picture

Nice feature! It would be great if it could work on every replaced field, not only labels. For core this would mean also the taxonomy term description. In this case the admin form should talk about "Field replacement settings" and "replaced fields".

plach’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/title.module
@@ -747,3 +756,37 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+  drupal_set_message(t('The field @field-name was attached automatically to  @entity-name - @bundle-name.', $params));

Double space here.

amitaibu’s picture

> on every replaced field, not only labels

What do you mean by that -- doesn't title handle only labels?

plach’s picture

What do you mean by that -- doesn't title handle only labels?

Nope :)

The field replacement API works with any field/property. In the field_replacement key of the entity info you'll find a list of replaced fields for that entity type. Architecturally Title should be split into two modules: a Field Replacement API module dealing with field replacement in a generic fashion and a Label module dealing with entity labels. Currenlty the module name is a bit misleading but initially we tought only about node titles. Then requiring a ton of modules just to make entities translatable didn't look so promising, and we kept a single module instead of splitting it.

amitaibu’s picture

> Currenlty the module name is a bit misleading

Indeed :)

> In this case the admin form should talk about "Field replacement settings" and "replaced fields".

Ok, so you mean that the settings for should be something like this, right?:

Node - Title
Term - Name
Term - Description
...
plach’s picture

Yes, exactly.

plach’s picture

[duplicate post]

roysegall’s picture

StatusFileSize
new24.21 KB
new3.49 KB

I upgraded the patch:
Title settings.png

amitaibu’s picture

+++ b/title.module
@@ -747,3 +756,34 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+ * Attach "Title field" automatically to the new bundle.

title field => replacement field

+++ b/title.module
@@ -747,3 +756,34 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+    // Don't continue if "Title field" already exists.

title field => replacement field

roysegall’s picture

If so - we need to change this:

Enable to auto-attach a title field when a bundle is created.

to:

Enable to auto-attach a replacement field when a bundle is created.

right?

amitaibu’s picture

yes

roysegall’s picture

Status: Needs work » Needs review
StatusFileSize
new3.51 KB
amitaibu’s picture

Status: Needs review » Reviewed & tested by the community
roysegall’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.51 KB

I made another fix that i think it's crucial - instead of return in line 776 i replaced it to continue.

plach’s picture

Status: Needs review » Needs work

I made another fix that i think it's crucial - instead of return in line 776 i replaced it to continue.

Yes, it's definitely a critical change. Tests should be adjusted to check that all the selected fields are actually replaced: they should have failed above.

+++ b/title.module
@@ -747,3 +756,34 @@ function title_field_replacement_hide_label($entity_type, $entity, &$variables,
+    $params = array(
+      '@entity-name' => strtolower($entity_info['label']),
+      '@field-name' => $entity_info['field replacement'][$field_name]['field']['field_name'],
+      '@bundle-name' => $bundle,
+    );
+
+    drupal_set_message(t('The field @field-name was attached automatically to @entity-name - @bundle-name.', $params));

For consistency can we have underscores instead of dashes in the parameters names?

roysegall’s picture

Yes. I'll change it and repatch

roysegall’s picture

Status: Needs work » Needs review
StatusFileSize
new3.51 KB

I apply the changes that plach suggested.

plach’s picture

@RoySegall:

Thanks for the new patch, but tests still don't check that all the selected fields for a given entity type are actually processed: we'd need to adjust the current test to check taxonomy name and description or write a new one, possibily as a full test case so that we would test also the administration UI.

plach’s picture

Status: Needs review » Needs work
roysegall’s picture

StatusFileSize
new3.86 KB

This patch apply a ui test for the patch(checking the messages that we receive from the module and submit the form).

roysegall’s picture

Status: Needs work » Needs review
plach’s picture

Committed and pushed, thanks!

I made a couple of minor fixes, interdiff attached.

plach’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.

  • Commit 27fda7d on 7.x-1.x, workbench authored by RoySegall, committed by plach:
    Issue #1704536 by RoySegall, Amitaibu, plach: Attach title field...