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!
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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.