문제

How do I specify the method of an action (similar to _delete):

generator:
  config:
    list:
      object_actions:
        myaction: {label: Label, action: myaction, method: post}

This ignores my method setting and renders a get link:

<a href="/backend/myaction/1">Label</a>

Whereas I want it to a "post" link, similar to _delete (with onclick attribute)

도움이 되었습니까?

해결책

I guess your using Propel.

If you check the generator code, specifically on: generator > theme_name > template > template > _list_td_actions.php, there you'll find a pice of code like:

<?php else: ?>
    <li class="sf_admin_action_<?php echo $params['class_suffix'] ?>">
      <?php echo $this->addCredentialCondition($this->getLinkToAction($name, $params, true), $params) ?>

    </li>
<?php endif; ?>

That's the code thats being executed when you define a custom object action like the one you described. Check $params and you may find a solution to your needs ( i think that probably you could define something like the onclick attribute value).

다른 팁

If you just want to have a confirmation message than probably the best way is:

generator:
  config:
    list:
      object_actions:
        myaction: {label: Label, action: myaction, confirm: "Are your sure?", params: {onclick: 'alert("Bu!");'} }

Additional parameters to link_to can be passed with 'params' option (notice 'onclick' in the example above).

maybe this will be useful

generator:
  config:
    list:
      object_actions:
        myaction:{ params: { onclick : "if(confirm('Are you sure?')){return true;}else{return false;}" } }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top