Page 1 of 1

Delegate class php file example

PostPosted: Sun Dec 25, 2011 7:03 am
by kedikatt
Maybe I just could not find the right place in the Wiki, but I had some trouble getting the delegate class file right due to finding only fragments.
So here is what I got working.

I wanted a field to have a default value filled in. The "function fieldname__default(){return 'something'}" does this.
The variables are fieldname and something.
Fieldname is the name of the field in your database.
Something is the value that you wish to have in the field by default.

<?php
class tables_tablename {
function fieldname__default(){
return 'something';}}
?>
The above example will fill in a field with a default value. The field would have the word "something" filled in.

<?php
class tables_tablename {

Above is the first section of the file. tablename is the name of the database table that the field, fieldname is in.
Notice the curly brace. The "function fieldname__default(){return 'something'}" goes in between a set of curly braces. Then finish off with ?>

I am not sure how you would place more than one function in this type of file. What syntax you might need as separators? What combination of curly braces?
This file has to be in a table directory. The same table directory that you would have fields.ini and valuelists.ini files in for instance.
Maybe a fuller example of this file structure could be added to the Delegate Class Wiki section?

Re: Delegate class php file example

PostPosted: Mon Dec 26, 2011 7:56 pm
by ADobkin
Hi kedikatt,

You might want to start by reading the Getting Started documentation:

http://www.xataface.com/documentation/t ... ng_started

In particular, there is a section/page that discusses how to set up the delegate class file with a few examples:

http://www.xataface.com/documentation/t ... te_classes

Good luck!

Re: Delegate class php file example

PostPosted: Mon Dec 26, 2011 9:26 pm
by kedikatt
Thank you! Fills a big hole in the concepts. Haven't finished reading the section yet, but already light bulbs turning on.