Fabrik Form: disable an element only in ADD form and avoid for EDIT

eulanaz

Member
Dear all,

I have a simple question that I didn't found on the network.

There is a way to run a specific javascript code for a single element only when we want to add a record?

I've created a little custom code using JS plugin in order to disable some elements. My problem is that this code is run in the EDIT form.

Thanks in advance

Cheers
eulanaZz
 
By "using JS plugin" I presume you mean the Javascript events in the element settings?

In which case no, we don't currently have an add/edit switch for that. It would be possible to add, but that would be billable work.

But if you are using custom code, ie. writing code in the "Javascript code" box rather than using the built in "if this do that" options, then you could just wrap it in ...

Code:
if (this.form.options.rowid !== '') {
  // do you stuff
}

-- hugh
 
Hi hugh,

thanks a lot for your answer.

Yes, I mean the Javascript events in the element settings.

I've temporary used the following code:

JavaScript:
var currentlocation = window.location.href;

var checkString = currentlocation.substr(currentlocation.length - 3);

// check if last 3 chars contains formid and / (i.e. 11/)
if (checkString === "11/") {
// disable element
var select = document.getElementById('table___my_column');
select.disabled = true;
}

I notice that when I'm into a form page there is always a / to the end of the URL.

Can be an alternative to do that.

Cheers
eulanaZZ
 
Yes, that's what the code I gave you in my previous post does. It checks to see if the form has a rowid.

Sent from my HTC6545LVW using Tapatalk
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top