⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Custom action control without going to another page



manfredrunkel
  • profile picture
  • Member

Posted 25 January 2013 - 16:02 PM

Hi! First of all i would like to write that im really happy with the Grocery crud. I'm a Java Developer, but this php framework is awesome (im new to php).

So, im doing a little project that i need to send an email with custom action control for the selected record.

I've added the action_control like this way:


[color=#0000FF]$crud[/color]->[color=#006600]add_action[/color][color=#66CC66]([/color][color=#FF0000]'Email'[/color], [color=#FF0000]''[/color], [color=#FF0000]''[/color],[color=#FF0000]'ui-icon-image'[/color],[color=#000066]array[/color][color=#66CC66]([/color][color=#0000FF]$this[/color],[color=#FF0000]'sendEmail'[/color][color=#66CC66])[/color][color=#66CC66])[/color];

but for every record, it starts this method sendEmail. On the sendMail i have my logic, that is started for every record.

I would like to stay on the same page and click on my action control logic and send my email.

Is that possible?

How can i do that?

Thank You

davidoster
  • profile picture
  • Member

Posted 25 January 2013 - 23:45 PM

You mean that it starts to send automatically emails when you load this page?

manfredrunkel
  • profile picture
  • Member

Posted 28 January 2013 - 10:49 AM

Hi David,

That's whats happening. When the page loads, it starts all my email logic. But, i dont want this.

Here is an image


[URL=http://imageshack.us/photo/my-images/521/grocery.png/][IMG]http://img521.imageshack.us/img521/7274/grocery.png[/IMG][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

I want to start my logic when the user click on Send Mail. It should even get the selected record, because i need the email from the User.

How can i do that?

I recognized that with add_action i was not able to do this.

Thank you

victor
  • profile picture
  • Member

Posted 28 January 2013 - 11:47 AM

you can make a Javascript function which will be do an action after click on the link. you can use a class for those links.

manfredrunkel
  • profile picture
  • Member

Posted 28 January 2013 - 12:05 PM

[quote name='victor' timestamp='1359373648' post='5319']
you can make a Javascript function which will be do an action after click on the link. you can use a class for those links.
[/quote]

Hi Victor, thank you.

Do you have an example? Only to add the listener and get some value from the record?

Thank you.

victor
  • profile picture
  • Member

Posted 28 January 2013 - 12:15 PM

no, I haven't.
I never do that )
step 1:


$crud->add_action('send mail', '', '','your_class',array($this,example'));

function example($primary_key , $row)
{
// you can return only id because the JS function only need the "id" to do action

return $primary_key
}


the link was created
step 2:

when user will click on this link the js function get an attribute "href" (in this case it's the "id" ).
then you can use AJAX methods for other actions.

I have no time (I make a project) to make it for you.

qeipami
  • profile picture
  • Member

Posted 17 January 2015 - 10:22 AM

no,don't work. it point just to example