Delegate class php file example

A place for users and developers of the Xataface to discuss and receive support.

Delegate class php file example

Postby kedikatt » Sun Dec 25, 2011 7:03 am

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?
kedikatt
 
Posts: 18
Joined: Sun Dec 25, 2011 6:25 am

Re: Delegate class php file example

Postby ADobkin » Mon Dec 26, 2011 7:56 pm

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!
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: Delegate class php file example

Postby kedikatt » Mon Dec 26, 2011 9:26 pm

Thank you! Fills a big hole in the concepts. Haven't finished reading the section yet, but already light bulbs turning on.
kedikatt
 
Posts: 18
Joined: Sun Dec 25, 2011 6:25 am


Return to Xataface Users

Who is online

Users browsing this forum: Google [Bot] and 14 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved