Page 1 of 1

Changing label name when in edit mode

PostPosted: Tue Jun 12, 2012 11:33 am
by clawes
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

Re: Changing label name when in edit mode

PostPosted: Tue Jun 12, 2012 11:20 pm
by Jean
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

Re: Changing label name when in edit mode

PostPosted: Wed Jun 13, 2012 10:45 am
by clawes
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!