Jump to content

return field value inside repeater inside TableField


sakkoulas
 Share

Recommended Posts

Hello everyone, im stuck on this problem

I have a page with a pageTable field that has a repeater field with three fields :)

Page 

   pageTable

      field name
       field date

      repeater
        field1 

        field2

        field3

   

I want to compare repeater field1 and field2 and get the field3 value … is this possible 
and what is the most correct way can i use (find) to compare field1 - field2 and return the field3;

for example 

foreach (pageTable as $pt){
   foreach ($repeater as $rp){
      
       if($rp->field1 >= $someValue && $rp->field2 <= $someValue){  // <- i cant make this line to work
           echo $field3;
       }
       
   }
}
 

   thanks

Link to comment
Share on other sites

Have you tried echoing the values through the code to make sure that your comparisons will work?

<?php

foreach ($page->pageTable as $pt) {
   
   foreach ($pt->repeater as $rp) {
   	echo $someValue;
        echo $rp->field1;
        echo $rp->field2;
        echo $rp->field3;
      	
       if( $rp->field1 >= $someValue && $rp->field2 <= $someValue ) { 
           echo $rp->field3;
       }
       
   }
}
Link to comment
Share on other sites

hello Macrura 

yes echo is showing the values 

all day im trying to compare the two fields and get the third, i disapointed and change the repeater field with pageTable so i can search for page id compare and move on...

thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...