Changing label name when in edit mode

Archived from the Xataface Users forum.

clawes — Tue Jun 12, 2012 11:33 am

I am looking for a way to change a widget label from “Create Account” to “Update Account” when I open the form for editing an existing record.
So it should say “Create Account” only when creating a new record. Otherwise, it should say “Update Account”

TIA


Jean — Tue Jun 12, 2012 11:20 pm

Hi,

I think you could try to insert into you table delegate class :

Code: Select all
function init(Dataface_Table $table){ if ( $query['-action'] == 'edit' ){         $myfield =& $table->getField('myfield');         $myfield['widget']['label'] = 'update account';     } }

cheers

Jean


clawes — Wed Jun 13, 2012 10:45 am

Thanks, Jean.

However, I had to make some minor modification to get it to work. It looks like $query method was not being instantiated in your code snippet.

Code: Select all
function init(&$table) {         $app =& Dataface_Application::getInstance();         $query =& $app->getQuery();         if ( $query['-action'] == 'edit' ) {         $myfield =& $table->getField('create_account');         $myfield['widget']['label'] = 'Update account?';              } }

Thanks again for pointing me in the right direction!