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

SOLVED Running calc depending on group repetition

Discussion in 'Community' started by Trembowiecki, May 8, 2021.

  1. Trembowiecki

    Trembowiecki Member

    Level: Community
    Hi,

    here's the thing: I want to use a repeating group for a timetable of installments. So in my form I have a field where you input amount of installments and then such amount of repeats appears below. Now is the tricky part: I use calc element in repeating group that devides the main amount of money by number of installments. The problem is - when I sum these installments, it nearly never gives the initial amount of money. You know - you have $10 and when you have 3 installments, you'll never gonna get these $10 with this method.

    So I thought that maybe there is a way to program calc to make it devide the debt by amount of installments minus one and make the last iteration of calc use other method - substraction of the installments minus one from the initial amount of money, so the last installment would be slightly different, but would make the overall timetable correct.

    Here's the question: is there a way to tell callc to behave differently on the last repetition of the group? If so - how?

    Cheers,

    Olek
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
  3. Trembowiecki

    Trembowiecki Member

    Level: Community
    Yep, I've started there, but obviously I'm not competent enough to actually access given repetition. I've tried various combinations of '{table___element}' with [number_of_repetition] with no luck. Help, please?...
     
  4. troester

    troester Well-Known Member Staff Member

    Level: Community
    Here is some more (it's from the php form plugin but should do at least partly also for calc)
    http://fabrikar.com/forums/index.php?wiki/php-form-plugin/#accessing-form-data

    Try if
    is doing in the calc.
    Use var_dump or the jdump plugin for debugging.
     
  5. Trembowiecki

    Trembowiecki Member

    Level: Community
    Unfortunately this method doesn't work - I get 'CALL TO A MEMBER FUNCTION GETELEMENTDATA() ON NULL' error.
     
  6. troester

    troester Well-Known Member Staff Member

    Level: Community
    I tested for you:
    $formModel->getElementData is working and I think additionally you have all data in $data.
    Did you use var_dump()? or
     
  7. Trembowiecki

    Trembowiecki Member

    Level: Community
    Nope, getElementData causes white screen with big error number at the center whenever I try to open my form.

    However I managed to access the desired group iteration with:

    $somevariable = $data['table___element'];
    return $somevariable[iteration_number];

    Simple as that, but since my programming skills are highly laughable, it wasn't obvious for me at all.

    Anyway - thank you for your time and patience, troester!
     

Share This Page