Changing label name when in edit mode

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

Changing label name when in edit mode

Postby 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
clawes
 
Posts: 22
Joined: Mon May 07, 2012 12:02 pm

Re: Changing label name when in edit mode

Postby 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
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: Changing label name when in edit mode

Postby 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!
clawes
 
Posts: 22
Joined: Mon May 07, 2012 12:02 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

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