Xataface 2: after_action_edit

60 views
Skip to first unread message

Roberto Brunelli

unread,
Oct 22, 2021, 4:03:13 AM10/22/21
to Xataface
Hi,

I would like to redirect the user, after successful editing of a record, to a 'report page' that is currently generated by an already available action (accessible via an appropriate button) via actions.ini:

[print]
  label       = "Stampa"
  description = "Stampa il form selezionato"
  order       = 11
  category    = record_actions
  icon        = "{$dataface_url}/images/printer.png"
  condition   = "$query['-table'] == 'scheda'"
  url         = "{$this->url('-action=report_print')}"
  permission  = print

and the corresponding php file:

class actions_report_print {

    function handle(&$params){
        $app             =& Dataface_Application::getInstance();
        $query           =& $app->getQuery();
        $query['-skip']  = 0;
        $query['-limit'] = 10000;

        if ( $query['-table'] != 'scheda' ){
            return PEAR::raiseError('This action can only be called on the scheda table.');
        }

        // $scheda = df_get_records_array('scheda', $query);
        $scheda    = df_get_records_array('scheda', $query);
        $scheda    = current($scheda);

        // do the job and report it
        echo '<html><body>';
      // generate relevant html report data
        echo '</body></html>';
    }
}

but I cannot understand from the available documentation hwo I can do this.
Any hint appreciated!!

Patrick Reinhard

unread,
Oct 23, 2021, 6:13:41 AM10/23/21
to Xataface

Patrick Reinhard

unread,
Oct 23, 2021, 9:44:50 AM10/23/21
to Xataface
Go to https://shannah.github.io/xataface-manual
and look for anchor:
Redirecting User to Different Page After Saving Record

Roberto Brunelli

unread,
Nov 18, 2021, 3:04:36 AM11/18/21
to Xataface
Uhm ... I've read the documentation you pointed me at but I cannot get it working with my stuff.

I've added

[edit > edit]
   after_action.scheda=report_print

but nothing happens. I managed to get to the page I want by adding

    function after_action_edit($params=array()){
        $record   =& $params['record'];
        $recordid = $record->getId();
        header('Location: '.'index.php?-action=report_print'.'&-recordid='.urlencode($recordid).'&--msg='.urlencode('Record successfully edited.'));
        exit;
    }

in scheda.php but it seems that I have problems when I use the backward page from the browser: the edit form I get back to after viewing report_print is sometimes (not always) the empty insert form (even if a 'scheda' is actually inserted into the database)

Roberto Brunelli

unread,
Nov 18, 2021, 3:08:49 AM11/18/21
to Xataface
more ... would it be possible to open the page in a new browser tab (so that the form remains with 'proper' content?

Patrick Reinhard

unread,
Nov 20, 2021, 11:04:58 AM11/20/21
to Xataface
What version of Xataface are you using?
I tried with version 3.0.0  and it works, while it doesn't with version 2.2.5
If you are using an older version, writing an after_action_edit function in the table delegate class - as you did - is the right way to get the desired result, as far as I know 


On Thursday, November 18, 2021 at 9:04:36 AM UTC+1 Roberto Brunelli wrote:

Patrick Reinhard

unread,
Nov 20, 2021, 12:50:36 PM11/20/21
to Xataface
I'm afraid this is not possible from the server side

Patrick Reinhard

unread,
Jan 10, 2022, 4:36:37 AMJan 10
to Xataface
To open your action in a new tab, you could try the

target="_blank"

parameter in your actions.ini, as found at https://groups.google.com/g/xataface/c/qR6bWBzdVus
Reply all
Reply to author
Forward
0 new messages