Wednesday, November 12, 2008

Directly modifying a table's attributes

While using the fields.ini is a good way to set attributes such as widget:label, description, etc sometimes you need more control. This can be accomplished by loading the table in the code and then directly modifying the fields. For example:


$usersTable =& Dataface_Table::loadTable('users');
$myfield =& $usersTable->getField('password');
$myfield['widget']['description'] = "Hello world";


The first line of code is retrieving a reference to the users table which is a Xataface table object. The table object comes with some functions that allow you with. One of them being the getField() function which would then retrieve a reference to the password field variable. From there we can access the widget attributes using arrays.

No comments: