Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Matt V.’s picture

I haven't tested it myself, but there appears to have been some work done towards a Drupal 8 version and there is an 8.x-1.x branch.

jmoreira’s picture

Hey guys,

I worked today in a version for this module for Drupal 8-beta12.
The only functionality missing is operations. I also plan to write some tests for this module if I have time.
I also created a repo on Github for this(https://github.com/jose-oliveira/auto_nodetitle), though I'm not sure if it's necessary.

Disclamer:
Though I've been working with Drupal for over 4 years, this is my first time actually contributing code to d.o., so forgive me if I'm not doing this right and feel free to teach me the right way. =D

jmoreira’s picture

Please ignore this patch and see next comment.

jmoreira’s picture

FileSize
20.79 KB

Here's a patch with the operations functionality. To make this work I also had to create an "Utility" class with the title generation functionality.

webchick’s picture

Status: Active » Needs review

Indicating that there's a patch here ready for review. Thanks for the work on this!

smerth’s picture

I downloaded the module from https://github.com/jose-oliveira/auto_nodetitle. I tried to applied the patches but they had already been applied the GitHub module. Any way everything seems to work fine for the title of a content type using tokens and a random hash, both for filling in the title and hiding and for filling in a blank title. But I found the module fails to interact with inline_entity_form. I submitted a separate issue for that.

Kristen Pol’s picture

Status: Needs review » Needs work
klokie’s picture

Title: Plans to port to Drupal 8? » Port Automatic Nodetitles to Drupal 8
Adams Latif’s picture

Please I will much grateful if you could work on the auto_nodetitle porting to drupal 8
I need it to complete my project please.

juliencarnot’s picture

Hi all and thanks a lot for your work on this module!

I learned about this module the hard way, by hiding the Title field in the form display tab of a fairly complex content type, then submitting the form and meeting a blank page and the following message in the log:

"Uncaught PHP Exception Drupal\\Core\\Entity\\EntityStorageException: "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null"

Could not find a way to display the title field again, and I guess D8 should not allow to hide it if it can't deal with a blank title, but I havent found a bug report on core yet, maybe I should file one...

Anyway, I took the code from the github 8.x-1.x branch today and it installed perfectly. I did not install the token module and then went to a new content type I've set and chose to hide the Title field and left the pattern field "blank for using the per default generated title", which I though would be good enough for now. I saved the config and went back to the form, but when submitting it, I get a nice red alert message "This value should not be null. ". I went back to the config and tried to use the "Automatically generate the title if the title field is left empty" setting and have the same error when I leave the field empty.

Adding some content in the pattern box such as abc, [token] or <?php return "Author: $node->name"; ?> and checking the php evaluation did not change anything, same error.

Is there something I'm doing wrong?

juliencarnot’s picture

Hi all,
I installed Tokens and gave it a try with the two different options (hiding title or not), with node-related tokens or with the random number token, on a custom content type or on the default "article" type, but I still have the red alert message "This value should not be null. " when creating or modifying a node. The "update automatic nodetitles" on /admin/content gives no error but no change is made to the titles.

In the log, I see this message:
Location http://***/admin/structure/types/manage/article
Referrer http://***/admin/structure/types
Message Notice: Undefined offset: 1 in Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies() (line 58 of /var/www/html/core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php).

I also occasionally see this one:
Location https://***/admin/structure/types/manage/resource
Referrer https://***/admin/structure/types
Message User warning: The following theme is missing from the file system: auto_nodetitle.auto_node_title in drupal_get_filename() (line 231 of /var/www/html/core/includes/bootstrap.inc).

I'd be grateful if anybody can give me a hint on these... I guess I should open new issues for this problem, but there is no 8.x version to tag them with... Thanks!

nflowers1228’s picture

I have the same issue as #10 I have attached screenshots
Name added to field with error message
Name added to field

How I configured Automatic Nodetitles - doesn't seem to be recognizing that the title field doesn't need to display
Name added to field

bdimaggio’s picture

Hey all - I have been playing with this a bit. Danielbeeke's pull requests on the Github repo address the problem described in #10 and #12, where the title field still is required when it shouldn't be. jmoreira, can you review and commit the pull requests? If not, I'm happy to pitch in, if you want to make me a collaborator on the repo. Thanks!

juliencarnot’s picture

Thanks for the notice @bdimaggio!

I checked the pull requests (replaced my auto_nodetitle module folder with the zip from Danielbeeke's repo, enabled auto_nodetitle and cleared the cache).

On the article content-type, I can now save a new article without the title. If leave the pattern empty, I have this warning:

Location http://***/en/node/add/article
Referrer http://***/en/node/add/article
Message Warning: htmlspecialchars() expects parameter 1 to be string, object given in Drupal\Component\Utility\Html::escape() (line 407 of /var/www/html/core/lib/Drupal/Component/Utility/Html.php).

If I enter a token, there's no error message on the screen but the log still shows this:

Location http://***/en/admin/structure/types/manage/resource
Referrer http://***/en/admin/structure/types
Message Theme hook token_tree not found.
Severity Warning

On my custom content type, I still have the same problem, using either the second or third option: can't save a new node, the message is still "This value should not be null.", with or without a token.

I get the same error in the log:

Location http://***/en/admin/structure/types/manage/resource
Referrer http://***/en/admin/structure/types
Message Theme hook token_tree not found.
Severity Warning

Now I'm wondering if I should use this issue or open a new one on the original github repo or the pull-request one! ;)

juliencarnot’s picture

OK, my last problem was with my custom content-type: it had a core.base_field_override.node..title set (don't remember setting that myself, might be from a previous version but who knows!), with a line "required: true", whereas my other content-types where auto_nodetitle worked had "required: false".

If anybody else is affected, you can check /admin/config/development/configuration/single/export and select Base field override or edit it directly with drush config-edit, find number for core.base_field_override.node..title and set required to false.

Would be great if a maintainer could make a dev release including Danielbeeke's pull requests on the Github repo for further testing, looks like it's pretty close to a releasable stage!

jpshayes’s picture

Is this branch up to date or do I need to patch with all the patches in this thread?

bdimaggio’s picture

@jpshayes, I'd use the github repo, being sure to apply those pull requests from DanielBeelke. The stuff on http://cgit.drupalcode.org/ looks old to me.

spacereactor’s picture

@bdimaggio i using the repo with DanielBeelke, Automatic Nodetitle work but token broswer is missing as shown at #12 and there a error log everytime you at content type edit page.

Theme hook token_tree not found.

gaurav.goyal’s picture

Status: Needs work » Needs review

Hi.

I have fixed the issue of token not available and generate a Pull Request. In the code we were using token_tree, and the according to this issue #2640138: Use token_tree_link instead of token_tree to render links , token_tree_link is used instead of token_tree.

gaurav.goyal’s picture

FileSize
45.21 KB

Forgot to attach image. Attached is the screenshot of configurations.

juliencarnot’s picture

Thanks @gaurav.goyal, your PR works well for me. No more token_tree not found errors and the tokens list works. I was surprised that it didn't include the [node:...fields....] tokens to set the title from fields filled when creating a node, but these tokens still work if entered manually.

I'm also still affected by the required setting in core.base_field_override.type.title (see my workaround at #15).

gaurav.goyal’s picture

Hi juliencarnot,

I tried to replicate the problem, but was unable to replicate it. I am not sure whether this is still an issue or not. For me everything was working as expected. It would be great if you can provide me the steps so that I can replicate it.

spacereactor’s picture

Thank gaurav.goyal for the token_tree_link but the node token are missing from the browser, example [node:content-type] but anyway autotitle still work with node token even it it not in the token browse list.

Got another question, I thought drupal 8 doesn't support php code insert for security reason.

Smith76’s picture

This release works well.
However, it does not support "Inline entity form".
Is there a planned integration of this module ?

charos’s picture

Since the module is working , is there going to be an alpha release one the projects branch?

Sutharsan’s picture

I have forked jose oliveira's github repo to fix the some errors. Pull requests are pending but no reply from him Jose yet. Feel free to use my repo: https://github.com/sutharsan/auto_nodetitle/tree/8.x-1.x

If it helps, I can co-maintain the module to create a D8 release.

juliencarnot’s picture

Thanks Sutharsan! Following your link, I see "This branch is even with jose-oliveira:8.x-1.x.", so I grabbed the last modified branch, "auto-title-service" and replaced the files on my install (8.04, lagging behind!), but I get this error on the create node page:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "auto_nodetitle.auto_title". in Drupal\Component\DependencyInjection\Container->get() (line 161 of core/lib/Drupal/Component/DependencyInjection/Container.php).

It would be great to have a D8 release, being so close to a fully functional state for this port... I haven't seen any replies from the maintainers in the lasts months, should we follow the steps for abandoned projects so that this release can be pushed out?

Sutharsan’s picture

@juliencarnot, I know the abandoned module procedure. But I prefer the 'front door' first. I have sent a DM to bless with a request for co-maintainer ship.

For a full picture of my works in the repo, you should combine all branches. Further there is no upgrade path, but I think rebuilding the cache should be enough.

mlncn’s picture

https://github.com/jose-oliveira/auto_nodetitle/tree/8.x-1.x worked for us. But instead of using an unsupported module we replaced it with:

/**
 * Implements hook_ENTITY_TYPE_presave.
 */
function mass_node_presave(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity->bundle() == 'person') {
    $entity->title->value = $entity->field_first_name->value . ' ' . $entity->field_last_name->value;
  }
}

:-)

Lowell’s picture

Issue summary: View changes
Lowell’s picture

Hadn't noticed this thread, seems a duplicate of here https://www.drupal.org/node/2608660#comment-11049271

We didn't mean to duplicate effort, this version is based on a fork of the jose-oliveira/auto-nodetitle branch and includes token support and a composer.json file so that it can be used as-is with the following composer command after adding this snippet to your site's composer.json repositories key.

    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/Lowell20/auto_nodetitle.git"
        }
    ],

composer require drupal/auto_nodetitle:dev-8.x-1.x

Hoping we can get any of these drupal 8 versions onto drupal.org

Sutharsan’s picture

I sent an email to both (co-)maintainers of the module, but got no reply. Looking at the state of the issue queue, this module looks to be un-maintained. Starting the abandoned module procedure as @juliencarnot suggested, will result in me taking over a module a badly maintained module. An I don't want that, I have plenty of contribution obligations already.

I plan to take a different route. I will start the Auto Title project. That will contain a Drupal 8 branch (only) and will support all entities and not just nodes. Development already started at: https://github.com/Sutharsan/auto_nodetitle/tree/auto-title-module

[Edit]: Plan changed.

Sutharsan’s picture

I found the Automatic Entity Label project.

Lowell’s picture

webchick’s picture

Sutharsan’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)

Technically, yes. But not sure it will bring us closer to a solution. I had a look at the code, auto_entitylabel 8.x is in pretty bad shape. Created two issues, now see how (if) the maintainers respond.

guttenbergovitz’s picture

I have to confirm the solution mentioned in #15 actually solves the problem of required node label. Had to drush cex, modify core.base_field_override.node.[nodename].title.yml drush cim to force it over current installation and use the option of hiding titlefield and overwriting it.

---

It actually did the trick. Token replacement using [node:field_fieldname] do work just fine.

---

As for auto_entitylabes » no luck with the same approach.

Lukas von Blarer’s picture

@Sutharsan I am currently using you auto_title branch. Works perfectly until now. Would you want to release this project since the maintainers of both projects are unresponsive?

Sutharsan’s picture

A maintainer of Auto Entity Label did respond and was interested in collaboration: #2659636-5: [Meta] D8 Port of Automatic Entity Label (AEL) Module I'm not keen on creating a third module with similar functionality. If you can't wait, feel free to use the code.

jeromerenders’s picture

Issue summary: View changes

This module works great with content types, but doesn't with terms title in Taxonomy (which is what I'm looking for).
Sorry if it's not the place to talk about this, I'm fairly new to Drupal development and I just can't find the module that automatically fill the term title with the concatenation of other term fields.

isimgt’s picture

I have a error in the node form:

Recoverable fatal error: Argument 2 passed to Drupal\auto_title\EntityDecorator::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, instance of Drupal\webprofiler\Entity\EntityManagerWrapper given, called in /core/lib/Drupal/Component/DependencyInjection/Container.php on line 276 and defined en Drupal\auto_title\EntityDecorator->__construct() (line 64 modules/contrib/auto_nodetitle/src/EntityDecorator.php).

Stephen Ollman’s picture