Form PHP

bea

Active Member
Hi Hugh,
I need you help to fix a problem with a form with different form PHP scripts. The scripts are running correctly, but I have a status element (dropdown: open/done), which should only available, when data from external table are already in the form. I've tried to set a javascript onload on one of this fields, to make the status element readonly, but this works only sometimes.
  1. load BDE data (onBeforeProcess): external data should be loaded into the form (list 1)
  2. deviation script (onBefore Store): generates records into another list when deviation from standard when status:done (list 2)
  3. next record script (onBefore Store): generates the next record when status:done (list 1)
When the user can select status, script 1 and 2 are running, before the BDE data is loaded.
How can I force the user to apply, to get all data into the form?

I know you are busy, but it would be great, if you have time the next days.

Cheers,
Bianka
 
Hey, sorry, I've been a bit swamped.

I responded in Skype. I'll need you to walk me through the issue, as I'm not really understanding your description.

-- hugh
 
Hi Hugh,

I would like to allow the user to select Status 'done' only, when external BDE Data (point 1) is already loaded in form.

Hope to catch you later.
Cheers,
Bianka
 
[...]I've tried to set a javascript onload on one of this fields, to make the status element readonly, but this works only sometimes.[...]
If it works only sometimes, try to envelope your javascript code inside a setTimeout... Something like this:
JavaScript:
setTimeout(
  function()
  {
    ...PLACE YOUR JS CODE HERE...
  }, 100);
 
Hi mauro,
many thanks for interesting hint. Yesterday I have skyped with troester about the 'unsave' js. In my case this should be absolutely save, because user are doing different stuff than they should do ;)

I've created an extra list for 'Status' and changed the dropdown to dbjoin (open=1, done=2). I put this script in advanced eval options, but need to do some more tests. Both element values come from external database. with form PHP.

PHP:
if($opt->value == 2) {
    if( (int) $data['fab_cp1_line_tour___effectiv_raw'] > 0 && (int) $data['fab_cp1_line_tour___losses1_transition_raw'] > 0 ){
        return true;
    } else {
        $opt->disable;
    }
}

Update: I have tried this script, but this doesn't block the Status 'done' all the time like the other script (apply/browser refresh):
PHP:
$effectiv = '{fab_cp1_line_tour___effectiv_raw}';
$transition = '{fab_cp1_line_tour___losses1_transition_raw}';
if($opt->value == 2) {
    if(!empty($effectiv) && !empty($transition)){
        return true;
    } else {
        $opt->disable;
    }
}
Cheers,
Bianka
 
Last edited:
I'm unable to understand your problem well because there are too little details (and, by the way, I'm a newbie of Fabrik) but, generally speaking, if you have to hide/unhide or disable/enable some field based on some condition, nomally I would do that with some javascript code related to the field you have to hide/unhide and maybe some validation test before the form submit (in the php form plugin) to avoid that a malicious user could do something he should not.

I suggested you to try the setTimeout(...) method because I noticed that sometimes a javascript onload event works always well only if you delay its execution by some milliseconds. This is expecially true when you 'fire' other events from inside the onload js event. But sorry, maybe this is unrelated to your problem...
 
Hi mauro,
my forms are to big with too many scripts, to put everything in forum. By the way, I'm here a long time, so I should know, but sometimes I don't ;)

But I found another way to solve my problem without JS.
  • I've created a new element, that is updated with 1st script (empty data = 1, !empty data=3)
  • now I can check against this element the script to create the next record
I ran into a known issue with !empty, where my '0' result was read as empty. But the additional element fixed this.

Have a nice weekend
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top