We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Add-on development: Is it possible to reference another field in a field group?

Development and Programming

Hoefler&Co.'s avatar
Hoefler&Co.
3 posts
5 years ago
Hoefler&Co.'s avatar Hoefler&Co.

I’m looking to create a select menu that just contains the count from a Grid field on the same page. So if a Grid field named “blocks” 3 rows, the select menu options would be “1, 2, 3”.

My use case: We need to create dynamic layouts for a home page, based on breakpoint. There are “blocks” of content entered into a Grid field. Then there are 6 other fields (one for each breakpoint) where they can select which blocks appear in which column for that breakpoint. Each of the “block” select menus should have an up-to-date count based on the “blocks” Grid field.

So, my new fieldtype needs to be able to listen to a specific Grid field and update its options when the Grid field changes.

Is this possible?

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
5 years ago
Brian Litzinger's avatar Brian Litzinger

There is an addRow jQuery event that is triggered when a new row is added. You could listen for that. It’s not documented so you’d have to inspect the Grid JS filed on GitHub to understand how it works.

There are also the events you can bind to, but not sure if that is what you’re looking for. These are mentioned in the EE docs.

Grid.bind('your_addon', 'display', onDisplay);
    Grid.bind('your_addon', 'beforeSort', beforeSort);
    Grid.bind('your_addon', 'afterSort', afterSort);

// Subscribe to the global event, will trigger for any Grid field on the page
    $(document).on('grid:addRow', function (element) {
        
    });
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.