Placeholders don't work in Eval Populate for checkbox?

Discussion in 'Standard Support' started by usdc-or, Nov 20, 2017.

Thread Status:
Not open for further replies.
  1. usdc-or

    usdc-or Member

    Level: Standard
    If I put quote marks around my placeholders e.g. '{tablename___elementname}' then the eval is seeing {tablename___elementname}, rather than the value of that element. If I don't use quote marks, an error is returned because of the curly bracket.

    I'm using some of these values in the query to get the checkbox options. Any advice would be appreciated.
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Works OK for me:

    https://www.screencast.com/t/zvzvNxtDPmf

    Obviously it's only going to have data when editing an existing record.

    The data we do the replacement with is in $data, so try ...

    var_dump($data);exit;

    ... as the first line, and see what's in there.

    -- hugh
     
  3. usdc-or

    usdc-or Member

    Level: Standard
    Thank you; I did just see it works fine on existing data, and so was clued into the issue. A bit odd that it returned the placeholder rather than a null value, but I was able to work around it.
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    That's actually an option in the function that does the replacement. So it's always a judgement call as to which option is best in any given scenario, whether to keep the placeholders or remove them if they aren't found. In general, I tend to err towards leaving them, as it often makes it more obvious what the problem is, when you see a placeholder where you don't expect it, rather than an empty string (which could mean lots of things).

    In this case, I think it's probably better to remove them. It's just never come up before - very few people use that feature, and even fewer us placeholders in it. In fact, you are the first person I can recall raising the issue.

    So ... I'll go and change the code to strip them ...

    -- hugh
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Oh, BTW, did you know you can use defaults in placeholders, with a || seperator?

    So {tablename___elementname||1} will default to 1 if the placeholder isn't found.

    -- hugh
     
  7. usdc-or

    usdc-or Member

    Level: Standard
    No, but that is awesome, thank you!
     
Thread Status:
Not open for further replies.

Share This Page