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

Discussion in 'Community' started by eulanaz, Nov 8, 2017.

  1. eulanaz

    eulanaz Member

    Level: Community
    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
     
  2. eulanaz

    eulanaz Member

    Level: Community
    friendly bump
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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 (Text):

    if (this.form.options.rowid !== '') {
      // do you stuff
    }
     
    -- hugh
     
  4. eulanaz

    eulanaz Member

    Level: Community
    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:

    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
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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
     

Share This Page