When creating a menu link, the title field is option. Menu's need titles, at least aesthetically. While they can exist without a title technically... they're really not meant to go without a title.

To best mimic core functionality, you cannot create a piece of content without the title field present. The form will submit, but the menu item does not save nor does a menu_link entity get created.

Comments

jnicola created an issue. See original summary.

jnicola’s picture

StatusFileSize
new570 bytes
jnicola’s picture

StatusFileSize
new1.41 KB

Okay, just requiring the title was silly, because even if the menu isn't enabled the menu field was required... it was silly :)

The New & Better approach:

  • Add element Validate
  • Add validation callback
  • Validation callback gets parent field, looks for enabled checkbox, and if so, make sure strlen of title > 0
  • Add title label class of required so it displays required
jnicola’s picture

Status: Active » Needs review
krina.addweb’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new163.03 KB
new162.75 KB

@jnicola, Thanks for the patch. I checked your patch with simplytest.me and got the issue by following the below steps:
1. Mark the menu_link field type as required under Article content type and save.
2. Create a node and click on the Provide a menu link under Menu Settings and Save.
3. In menu setting despite it is a Required field it is showing that field is not required.
It is working fine. PFA

jnicola’s picture

Status: Reviewed & tested by the community » Fixed

Brought into latest dev branch, fixed!

Status: Fixed » Closed (fixed)

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