No announcement yet.

Update a form field from within the code of PHP Button in a Control Form

  • Filter
  • Time
  • Show
Clear All
new posts

  • Update a form field from within the code of PHP Button in a Control Form

    I'm working with SC7 v.7.00.0017

    I have build a control form with several text fields, for example {IdPortal}.
    Then, I have added a PHP button, named "B3", with code uses sc_lookup macro to find a value in a table field, which is assigned to the variable {IdPortal}.
    I have checked that the value is found and assigned to the the field variable {IdPortal} writing an echo command to show it.
    In run time, when I click this custom "B3" button, the screen shows a new screen with an "OK" button (żis normal?)
    Then, when I click this "OK" button, SC returns to the original control screen from which the execution began, but doesn't change the value in the {IdPortal} field, despite the code has explicit changed it.

    Is a bug ?

    If I write just the same code in the OnValidate event, the desired behavior is accomplished when I click in the OK button of the control form: the {IdPortal} form field shows the new value, and no other screen is shown.

    Why the behavior is different ?

    Best Regards,

  • #2
    The question is how run a code php into a button type php and form do not navigate.
    why if the button is type javascript not navigate


    • #3
      The OK button is standard behaviour. You can avoid this by doing a sc_redir after the procedure to the same application. There have been a few additional feature request to change this. But I don't know the status of these requests.
      Be aware that if you do a sc_redir you have to take care to retrieve the correct record. I use a global variable to get this done, but perhaps there are better means.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development /


      • #4
        [Solved] Ok.... I have tried to update the variable field {IdPortal} from within the php button code and add sc_redir macro at the end of this code to avoid the blank new screen with the OK button. All fine except for the updated field which shows no value (as all the other indepentent text fields of the control form). It seems the standard behaviour in to reset allthese non database fields in the form after execute the php button code.

        So, I should save the form fields values in global variables before to return execution from the php button code to the control form and then assign the values of these global variables to the form fields in an event of the control form...I am not sure which event... Have to try.

        Thank you for the kindly support.

        Last edited by ftuteleers; 07-06-2013, 04:28 PM.