Jump to content


add_action return not working

add_action form

  • Please log in to reply
8 replies to this topic

#1 mavershim

mavershim

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 17 April 2013 - 07:48 AM

Hi,

 

I have a condition on my add_action but everytime i look at the action column I still see the button

 

if ($this->bitauth->has_role('OLA-AO'))
        {    
            return site_url('closecases').'/'.$row->caseno.'/add';
        }
        else{
            return '';
        }

 

in my action column i always have a button and its link is always the first. how can i make the action button disapear when the condition is not met.



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 18 April 2013 - 06:36 AM

This is not related to Grocery CRUD actually.

You need to check what this bitauth library is supposed to return and if you called it correctly.

So you need to check what it gives you the 

$this->bitauth->has_role('OLA-AO') part of your code.

I wish I could help you more but I haven't used the bitauth library!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 mavershim

mavershim

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 18 April 2013 - 07:44 AM

the url is changed but the button is still showing in the action column



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 18 April 2013 - 08:49 AM

Ok let me explain in more detail.

You are using this format to call your callback function,

 

$crud->add_action('Photos', '', '','ui-icon-image',array($this,'just_a_test'));

 

right?

When you call this function add_action (no matter what the callback does) it will display an icon, because of the 'ui-icon-image' css definition.

If we assume that this needs to be displayed only when 

$this->bitauth->has_role('OLA-AO') == true

 

I would change your code like this 

within your controller

if ($this->bitauth->has_role('OLA-AO')) // your add_action;
    

 

and then at your callback I would just havereturn site_url('closecases').'/'.$row->caseno.'/add';

It's just a matter of logic and point of view.

 

What I said before is NOT on a per row basis. If you needed on a per row basis then this code needs to be changed.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 mavershim

mavershim

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 18 April 2013 - 08:51 AM

thanks for the reply but i'm looking on a per row basis...



#6 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 18 April 2013 - 09:04 AM

It didn't show on your original post though!

 

 

controller:

$crud->add_action('Photos', '', '','',array($this,'just_a_test'));

 

callback

/* somewhere here you need to mix and match the if statement with the $primary_key, $row data
   only like this you get on a per row definition of the returning url
   within style='' put anything you want or within class/id for the css definition
*/
if ($this->bitauth->has_role('OLA-AO') && $primary_key == 1)
        {    
            return "<a href='' class='' id='' style=''>the text you want</a>";
        }
        else{
            return "whatever you need";
        }

 

 

 


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#7 mavershim

mavershim

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 18 April 2013 - 09:33 AM

hi davidoster,

 

thanks. but the problem with this is that it will always be enclosed on the href. grocerycrud has a default of

 

<a href=''" class=" crud-action" title="Closed"></a>   

 

so if I return something  like this

 

<a href="<a href=.... class="Closedcrud-action"><image></image></a>" " class=" crud-action" title="Closed"></a>    



#8 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 18 April 2013 - 10:01 AM

This is the first time I noticed that! I didn't suspect that you can't do it!

I was hopping that the callback allows you to completely replace the full <a /> structure.

 

Have you tried using (instead of all these) the callback_column function?

different logic but it will work!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#9 mavershim

mavershim

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 18 April 2013 - 10:04 AM

no but I have to recreate the action column where the other button is located (edit,..)







Also tagged with one or more of these keywords: add_action, form

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users