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

MX Cloner & Grid

Developer Preview

Max Lazar's avatar
Max Lazar
341 posts
about 12 years ago
Max Lazar's avatar Max Lazar

Hello Team, I meet with problem that my add-on MX Cloner, is not working with Grid FT. Cloner is very simple free add-on which repeat logic EE1 Cloner from EL and it works fine with any FT except which has they own logic linked to separate records. When I have the same problem with Matrix in past, Brandon just integrate check cond for clone entry into field name logic. It is also can be done easily the same way with grid - just check the url for ‘clone’ variable (like in original cloner) and if yes - mark row as new.

For this needs to make replace in /system/expressionengine/fieldtypes/grid/libraries/Grid_lib.php

replace this:

// If row_id is set, perform an extra check before assigning it in case
        // we are coming back from a validation error
        if (isset($row['row_id']))
        {
            $row_id = (is_numeric($row['row_id']))
                ? 'row_id_'.$row['row_id'] : $row['row_id'];
        }

with this:

// is this a clone?
        $clone = (ee()->input->get('clone') == 'y');
 
        // If row_id is set, perform an extra check before assigning it in case
        // we are coming back from a validation error
        if (isset($row['row_id']))
        {
            $row_id = (is_numeric($row['row_id']))
                ? ( ($clone) ? 'new_row_' : 'row_id_').$row['row_id'] : $row['row_id'];
        }

Be true - of course I can also make Grid support inside Cloner by writing JS code which will do field name replacement in front end. But this worse way.

Possible I missed some solution and you can advice better way to modify grid row name.

Thanks!

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
11 years ago
Kevin Cupp's avatar Kevin Cupp

Hi Max,

Sorry we missed this, we generally don’t monitor this forum unless we’re in the middle of dev preview. You can feel free to email us anytime though.

We usually don’t like to add add-on specific code to EE, unless it’s otherwise generally useful. Do you think you could instead use something like the entry_submission_start hook, and then modify the POST data to replace row_id_ with new_row_?

Kevin

       
Max Lazar's avatar
Max Lazar
341 posts
11 years ago
Max Lazar's avatar Max Lazar

Hi Kevin, yes, i think that this is possible. Shame on me - i don’t saw such simple solution. And I actually already have this hook inside (to cleanup entry_id) Thanks!

       

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.