Problem/Motivation

Using Entity API programmatically, when default state for sharing buttons per node is activated (better_social_sharing_buttons_per_node submodule), node was created with value FALSE for better_social_sharing_buttons_active field and not with default state for sharing buttons per node of node type.

Steps to reproduce

  • Activate better_social_sharing_buttons and better_social_sharing_buttons_per_node modules
  • From node type edition, "/admin/structure/types/manage/a_node_type", see _better_social_sharing_buttons_configured_node_type.png screenshot
    • Check Enable Social Sharing Buttons and Allow to enable/disable sharing buttons per node properties
    • Choose Enabled for Default state for sharing buttons per node property
  • Execute Node::create([ 'type' => 'a_node_type', 'title' => 'A title', 'status' => 1, 'uid' => 1, ])->save();
  • Go to the created content and see that Display the social sharing buttons property is not checked, see _better_social_sharing_buttons_created_node.png screenshot

Proposed resolution

Adding a hook hook_entity_bundle_field_info in order to set default value for better_social_sharing_buttons_active field of node depending on default state for sharing buttons per node configured for the node type.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dpiet created an issue. See original summary.

dpiet’s picture

Title: Set default value for 'better_social_sharing_buttons_active' field per node type function default state for sharing buttons per node of each node type (better_social_sharing_buttons_per_node submodule) » Set default value for 'better_social_sharing_buttons_active' field per node type
Issue summary: View changes

dpiet’s picture

Here is a patch to add " set default value " feature for 4.x version.

dpiet’s picture

Here is a patch to add " set default value " feature for 5.x version.

dpiet’s picture

Assigned: dpiet » Unassigned
Status: Active » Needs review
dpiet’s picture

Issue summary: View changes
shelane’s picture

Status: Needs review » Needs work

Please submit as an MR to the 5.x branch please. I am not accepting new features for the 4.x branch.

dpiet’s picture

Version: 4.1.0 » 5.0.0-beta1
Status: Needs work » Needs review

Hi shelane, there was the MR !44 I pushed on 5.x. I have just rebased it.

mably changed the visibility of the branch 3568292-set-default-value to hidden.

shelane’s picture

Status: Needs review » Fixed

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.

dpiet’s picture

Thanks for the merge and the credit @shelane.

Status: Fixed » Closed (fixed)

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