1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Table edit link doesn't work when using pre-filter passed from URL

Discussion in 'Standard Support' started by mlinden, Mar 22, 2011.

Thread Status:
Not open for further replies.
  1. mlinden

    mlinden New Member

    Level: Community
    I seem to be testing all the edge cases on this project.

    I'm using a placeholder in a prefilter {code} to take the value from &code= at the end of a URL (to display just a single record in a table).

    (URL looks like this: index.php?option=com_fabrik&view=table&tableid=5&resetfilters=1&code=xyz)

    Unfortunately when doing this, although the pre-filter works fine, the edit link on the table doesn't work.

    When clicking on the edit link I get a URL which looks like this:

    index.php?option=com_fabrik&c=form&view=form&Itemid=0&fabrik=5&rowid=29&tableid=5

    and an error message which says:

    "We were unable to find the record (id = 0) in the database"

    If I just put the value into the pre-filter manually on the backend I get a URL that looks like this:

    index.php?option=com_fabrik&c=form&view=form&Itemid=60&fabrik=5&rowid=29&tableid=5

    and it works fine.

    Is there any way of getting round this, such that the pre-filter can be passed in by URL and the edit link work?

    (For example would it be possible to use the custom edit URL for this? and if so what needs to go in there?)
     
  2. mlinden

    mlinden New Member

    Level: Community
    Friendly bump
     
  3. pastvne

    pastvne Bruce Decker

    Level: Community
    I'm new but have you tried the custom edit URL in the table specification encoded as:

    If that leaves off the rowid= (I think Fabrik adds that automagically) then try hard-coding the id into the URL as:


    Where:

    XXX is the number of your form
    your_full_tablename is your full table name including prefix
    ___ is three underscores
    your_id_fieldname is the field in your table holding the internal id


    My apologies in advance if this advice is rubbish, I'm trying to give back with what little knowledge I have.
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    You could try pastyne's suggestion (and yes, we should append &rowid=X automagically). That will route the building of the edit link through a different method internally.

    However, I think it still get $Itemid from the same place. Which is what confuses me ... the only difference I can see in the links from the original post are that one has Itemid=60, and one has Itemid=0. And I'm not sure why pre-filtering in a query string would cause us to lose the Itemid .... or why providing a Userid of 0 would cause that 'can't find record' error.

    I'm trying to track this down locally.

    -- hugh
     
  5. mlinden

    mlinden New Member

    Level: Community
    Hi Pastyne,

    Thanks very much for your reply.

    The first custom URL (index.php?option=com_fabrik&c=form&view=form&fabrik=5) does what you predicted, it strips out the itemid. (However clicking on edit still generates the error message "We were unable to find the record (id = 0) in the database")

    When I use the second custom URL:

    index.php?option=com_fabrik&c=form&view=form&fabrik=5&rowid={despatch___id}

    rowid gets added into the URL twice:

    /index.php?option=com_fabrik&c=form&view=form&fabrik=5&rowid=&rowid=29

    and the error message "We were unable to find the record (id = 0) in the database" still gets generated.

    I have no doubt misunderstood the syntax of your suggestion for the second custom URL, in which case I'd be grateful if you could correct me.

    (I'm sure this isn't really the place for a bug report, but every time I save the table, the prefilter defaults back to type "eval" and ceases to work... I then have to go back into it the table and reset the pre-filter type so that it will work again.)

    I'd be really grateful for any other suggestions as to how to get round this as the site is supposed to go live within the next few days.

    Thanks again.
     
  6. pastvne

    pastvne Bruce Decker

    Level: Community
    Another Hack

    I think hugh is probably on a better track than I am. I'm not sure what ItemID holds in terms of the URL being passed. But if it is the same value across all records in this table, then you could hard-code the ItemID param into the URL and give it a whirl. Of course, hugh will probably have discovered a bug and fixed it is SVN by the time you read this and that could break this hack. There are two parts:

    1) hard code the ItemID (with the proviso above)
    2) remove the &rowid= from the code but keep the table.field placeholder.

    This may cause:
    1) The ItemID to be fed properly to the method
    2) The rowid to be properly encoded in the rendered URL

    But still, remember that you may have to back out the custom URL if a bug is discovered and fixed in the Fabrik SVN.


    Here is the revised custom URL:
    -or possibly (sans training ampersand)-

     
  7. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Itemid is a Joomla thing. It's the ID of the menu item for the page you are on. That's how Joomla knows which menu item to render as selected when you load other associated pages - like when you add a new form from a table which you have a J! menu item for, the new form page will keep that menu item selected.

    What I currently have no clue about is a) why we're dropping the menu Itemid when you use {code} in a pre-filter, and b) why that would cause the 'can't find record 0' error.

    @mlinden - it you want to find me on Skype ('cheesegrits') I'll take a look at your site, see if I can work anything out.

    BTW, when you say {code}, are you literally using &code=X, or some other query string arg name?

    -- hugh
     
  8. mlinden

    mlinden New Member

    Level: Community
    Hi Hugh,

    I'll try to get hold of you later today.

    Thanks.

    Matthew
     
  9. mlinden

    mlinden New Member

    Level: Community
    Hi Hugh,

    Didn't manage to get hold of you on Skype.

    To save time, I've decided to do this by removing the table prefilter altogether and going directly to a form update url rather than displaying the table row with edit.

    (The 'can't find record 0' error message is still very much there - even when going directly to the form update url - when using {} in the table pre-filter).

    If it does occur to you at any point what the problem might be in using the placeholder in the pre-filter I'd be grateful if you could update this.

    Many thanks for your help in any case.
     
  10. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    OK. I'll do some more testing on this and let you know.

    -- hugh
     
  11. rob

    rob Administrator Staff Member

    Level: Community
Thread Status:
Not open for further replies.

Share This Page