1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Repeating Group Date field being populated with value from parent group date field...

Discussion in 'Community' started by cheyennemtnman, Apr 20, 2021.

  1. cheyennemtnman

    cheyennemtnman Member

    Level: Community
    Can this be done with a Calc Element? Then can it be carried over when adding a new repeat group?
     
  2. juuser

    juuser Well-Known Member

    Level: Community
    What happens when you add:
    return '{yourtable___parent_group_date_element}';
    to the repeat group calc element? And "Only calc on save" to "No"?
     
    cheyennemtnman likes this.
  3. cheyennemtnman

    cheyennemtnman Member

    Level: Community
    What I really need is to place a date in the repeatable field based on the parent date
    I wanted to use the date in parent date and then calculate the date 5 days prior...
    Could I use something like this in a calc element to populate the repeating date field but it could be changed by the user by the date selector or by entering date in manually.

    $days_ago = date('m-d-y', strtotime('-5 days', strtotime('{yourtable___parent_group_date_element}')));
    return '$days_ago';
     
    Last edited: Apr 22, 2021
  4. juuser

    juuser Well-Known Member

    Level: Community
    In that case you should be able to replace your calc element with a date element and put the code in your last post into date element's "default" field and set "Eval" to "Yes".
     
    cheyennemtnman likes this.
  5. cheyennemtnman

    cheyennemtnman Member

    Level: Community
    Will I run into the same problem with the "m-d-y" format instead of the other way?
     
  6. cheyennemtnman

    cheyennemtnman Member

    Level: Community
    Seems I did... got this error....
    An error has occurred.
    0 DateTime::__construct(): Failed to parse time string ($days_ago) at position 0 ($): Unexpected character
     
  7. juuser

    juuser Well-Known Member

    Level: Community
    Check what happens with:

    $days_ago = date('Y-m-d H:i:s', strtotime('{yourtable___parent_group_date_element_raw}' . ' -5 days'));
    return $days_ago;

    Also note that quotation marks around variables can cause problems (return '$days_ago')
     
  8. cheyennemtnman

    cheyennemtnman Member

    Level: Community
    The jdate element is set as m-d-y in both list and form... will that be a problem when using Y-m-d H:i:s

    I get -
    An error has occurred.
    0 DateTime::__construct(): Failed to parse time string ($days_ago = date('Y-m-d H:i:s', strtotime('{Your_table__date_raw}' . ' -5 days')); return $days_ago;) at position 0 ($): Unexpected character
     
    Last edited: Apr 23, 2021
  9. juuser

    juuser Well-Known Member

    Level: Community
    I don't have time to test now, but dump the variables and see if you get the correct dates like:

    var_dump('{yourtable___parent_group_date_element_raw}');
    exit;

    and

    var_dump($days_ago);
    exit;
     
    Last edited: Apr 23, 2021
    cheyennemtnman likes this.
  10. cheyennemtnman

    cheyennemtnman Member

    Level: Community
    I will do so!
     

Share This Page