1. Hugh is now back at work, more or less full time, after a slower than expected recovery from his neck surgery early this month. Obviously we have a backlog of support to clear, and are working as hard as we can to take care of it. If you have an unanswered thread more than 3 days old, please post one (and only one) "bump" on it, to move it in to our "last 3 days" list. If you have an unanswered issue in a forum you no longer have access to due to subscriptions timing out, please use the Contact Us form, and provide us with the URL to the thread.

Hide or Show element

Discussion in 'Fabrik 3.x Testing' started by jacardiel, May 5, 2012.

  1. jacardiel New Member

    Level: Community
    Hi,
    i have an image element ("Reservar"). I want hide or show it, depend on the value the field "reservado" has.
    If reservado='S' then the image element "Reservar" should hide, and if reservado='N' then show, but I don't achieve thet work well.

    I Attach the configuration of this element.

    Thanks

    Attached Files:

  2. troester Well-Known Member

    Level: Standard
    It's vice versa: you must add the JS to your Reservado element
    hide reservar (= the image element) if this (=element Reservado) == 'S'
  3. jacardiel New Member

    Level: Community
    OK now work well when I load the form, but not work well in a list.
    I call to list from a item k2.{fabrik view=list id=5 cachorros___id_camada=2 layout=default}
    What is the problem in the list?
  4. jacardiel New Member

    Level: Community
    can anyone help me with this?
    Thanks
  5. jfquestiaux Well-Known Member

    Level: Professional
    The JS settings of the element won't work in the list.
    You should use a "calc" element to display the path of your "reservar" image based on the value of the other element.
    1 person likes this.
  6. jacardiel New Member

    Level: Community
    Hi,
    i install the calc plugin and i add a new calc element at the same table. I write the next code, but don't work well. What is the problem?

    if ($cachorros___reservado=='N')
    {
    $cachorros___reservar=='images/reservar_cachorro.jpg';
    }
    else
    {
    $cachorros___reservar=='';
    }
    Thanks
  7. rackem Well-Known Member

    Level: Community
    You need to use PHP in the calc element (more info in the wiki) so something like this:
    Code (text):

    if ('{cachorros___reservado}' == 'N')
    return "images/reservar_cachorro.jpg";
    else return "";
     
    1 person likes this.
  8. jacardiel New Member

    Level: Community
    Ok, with this code I obtein the right value depend on the element reservado, but How assign I this value to the image element "reservar" for show or not the image?

    Something like this don't work

    if ('{cachorros___reservado}' == 'N')
    '{cachorros___reservar}'=="images/reservar_cachorro.jpg";
    else '{cachorros___reservar}'=="";

    Thanks
  9. jfquestiaux Well-Known Member

    Level: Professional
    Try this :
    Code (text):
    if ('{cachorros___reservado}' == 'N') {
    return '<img src="images/reservar_cachorro.jpg">';
    } else {
     return ' ';}
  10. jacardiel New Member

    Level: Community
    this code work well in list but not in form. Any idea?
    Thanks
  11. jfquestiaux Well-Known Member

    Level: Professional
    In edit view, the JS code in the JS tab of the element should do the trick.
    When you say it does not work in form, I guess you mean detail view.
    For that you need to edit/save the record so the value of the calc is recorded in the database (otherwise it is displayed in the list "on the fly" via Ajax). Once it is recorded in the database, it should be displayed in the detail form also (I think it used not to, but this was corrected some time ago).
  12. jacardiel New Member

    Level: Community
    In the list work properly.
    Whe i say form, I want to say detail view how you well guess.
    I attach two images, in olist view you can show that the element calc "prueba" work well depending on the reservado value, but in detail view, not,
    If i edit the detail view ad save, the list refresh well but when i access to detail not. Any idea?

    Thanks

    Attached Files:

  13. jfquestiaux Well-Known Member

    Level: Professional
    Can you provide the url of the page so we can try to debug?
  14. jacardiel New Member

    Level: Community
    Actually I Develop the site in local with xampp
    Can i send you something moré for testing?

    Thanks
  15. rackem Well-Known Member

    Level: Community
    Have you tried using the full path to the image in your calc element code? In your previous code, your path is relative ("images/reservar_cachorro.jpg"). So, for example, try http://localhost/sitename/images/reservar_cachorro.jpg. Just a thought, not sure if it will make a difference seeing as how it is working for your list.
  16. jacardiel New Member

    Level: Community
    Don't work also with absolute path

Share This Page