1. The forums have been upgraded to XenForo 1.4. Please post any issues or comments here.
  2. Our hosting provider will be performing some scheduled maintenance and upgrading during the early morning (US time) of Tue 28th July, starting at approx 2am EST, which will require some down time of the server.

Hide or Show element

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

  1. jacardiel

    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

    troester Well-Known Member Staff 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

    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

    jacardiel New Member

    Level: Community
    can anyone help me with this?
    Thanks
     
  5. jfquestiaux

    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

    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

    rackem Well-Known Member

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

    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

    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

    jacardiel New Member

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

    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

    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

    jfquestiaux Well-Known Member

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

    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

    rackem Well-Known Member

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

    jacardiel New Member

    Level: Community
    Don't work also with absolute path
     

Share This Page