7 Replies Latest reply on Feb 3, 2012 12:11 PM by jpedmd

    PHP API and repeating fields


      OK, I know I should not be using repeating fields, but I have a legacy repeating field that I'd like not to have to untangle immediately. I'd like to be able to display 2nd repetition value on a web page, but nothing I am doing seems to work. Have tried $record->getField(example_ra', 2), $record->getField('example_ra', '2'), $record->getRepetition('example_ra', 2), $record->getRepetition('example_ra', '2')


      and nothing works. I suspect I am missing something obvious, but not sure what. Can anyone help?



        • 1. Re: PHP API and repeating fields

          From my interpretation of the PHP API documentation I understand that

          field repetition count starts at 0. So, $record-getField(example_ra', 1)

          should yield the second repetition.


          (Oh my! Have to remember that when I will migrate our XSLT files. Here,

          repetitions start at 1).




          ETH Zuerich

          Dr. Martin Braendle

          Informationszentrum Chemie Biologie Pharmazie

          HCI G 5.3

          Wolfgang-Pauli-Str. 10

          CH-8093 Zuerich





          +41 44 632 29 48 Telefon

          +41 44 633 12 87 Fax








          Von:  jpedmd <noreply@filemaker.com>

          Antworten an:  <fmi-1911571543-2yn-2-1hbh@fmdev.filemaker.com>

          Datum:  Thu, 2 Feb 2012 08:14:59 -0800

          An:  Martin Brändle <braendle@chem.ethz.ch>

          Betreff:  PHP API and repeating fields














              created by jpedmd <https://fmdev.filemaker.com/people/jpedmd> in Using

          Web Technologies - View the full discussion


          • 2. Re: PHP API and repeating fields

            This is in the cwp_xslt guide, but not the cwp_php guide.



            About the syntax for a fully qualified field name

            A fully qualified field name identifies an exact instance of a field. Because fields with common names can be based on different tables, you must use fully qualified names, in some cases, to avoid errors.

            The syntax for specifying a fully qualified field name is:





            1     table-name is the name of the table that contains the field. The table name is only required if the field is not in the underlying table of the layout specified in the query string.

            1     field-name(repetition-number) is the specific value in a repeating field, and is only required for repeating fields. The repetition number starts counting at the numeral 1. For example, field-name(2) refers to the second value in the repeating field. If you don’t specify a repetition number for a repeating field, the first value in the repeating field is used. The repetition-number is required for the –new and –edit query commands involving repeating fields, but it is not required for the –find command.

            1     record-id is the record ID, and is only required if you are using a query string to add or edit records in portal fields. See the following sections “Adding records to a portal,” and “Editing records in a portal.” The record-id is required for the –new and –edit query commands involving portal fields, but it is not required for the –find command.

            Note To be accessible, fields must be placed on the layout you specify in the query string.



            In fact, I could find nil for Repetitions in cwp_php guide (except error codes).


            I'd hazard to guess that with PHP, the index does start at 0, not 1. I'd like to see documentation on it.



            • 3. Re: PHP API and repeating fields

              From the  API documentation (not the guide):


              " getField (line 86<file:///Users/braendle/Desktop/PHP_Schulung/Sourcecode/Dokumentation/FM%20API%20Dokumentation/__filesource/fsource_FileMaker__FileMakerRecord.php.html#a86>)


              Get the HTML-encoded value of $field.



              •   return: The field value.


              string getField (string $field, )



              •   string $field: The field name to fetch.


              •   integer $repetition: The repetition number to get, defaults to the first repetition."


              $repetition = 0 --> defaults to the first repetition





              1 of 1 people found this helpful
              • 4. Re: PHP API and repeating fields



                I can confirm that field repetitions do indeed start with 0.  So as Martin has said, $record-getField(example_ra', 1) should provide the second repetition.


                As for documentation of this, I don't know of anything declarative either.  In the PHP API Documentation that comes w/ FMServer, however, under "Class FileMaker_Record", the optional parameter for field repetitions does show a 0, which would be the default of the first repetition:


                string getField (string $field, [integer $repetition = 0])


                FWIW: In a standard FMS install on Mac, you should be able to see the page at:







                Joel Shapiro

                FileMaker Pro

                : database design

                : web development




                1 of 1 people found this helpful
                • 5. Re: PHP API and repeating fields

                  Joel, that's the link I was looking for! I have the PHP API documentation, but couldn't remember where I got it, so I could pass it on...


                  This link may help also from the FMI site.  http://www.filemaker.com/downloads/zip/PHP.zip (A zip of the the PHP tutorial and some sample files.)


                  The code in Martin's reply seems to have been munged (it has a link on it), but also has the answer!

                       string getField (string $field, [integer $repetition = 0])




                  • 6. Re: PHP API and repeating fields

                    Glad I could help, Beverly :-)


                    For anyone else watching, the main page to the PHP API documentation is at:





                    And while I'm at it... FWIW, you can view the general FMP help in your browser too (based on standard Mac install of FMPA), at:



                    Nice to have bookmarked  :-) 




                    • 7. Re: PHP API and repeating fields

                      Thanks, everyone.  Should have guessed might follow PHP array numbering rules. For me at least, I can confirm that:

                      $record->getField('example_ra', 1 ) 

                      works to get a second repetition of field 'example_ra',

                      $record->getField('example_ra', 2 )

                      gets the third, etc.   Note no quotes or brackets around the repetition number.