I'm using entity reference prepopulate and views. On the start of my node add form I'm using views to display some products and I have created a PHP button to pass the nid of those products to the URL. Here is the code:

$url = token_replace('[current-page:url]'); 
$l = l( t('SELECT THIS VENUE'), $url,  array('query' => array('field_product_venue' =>$row->nid )  ));
echo $l; 

And on the last part of my node add form the user can see the summary of all the products he or she has chosen but he or she must also have the ability to remove those items, since the form gets its selected products from the url I want to create a button that deletes that specific product (nid) from the URL.

Any help would be greatly appreciated.

| improve this question | | | | |

You need to get the value of the parameter, then check if the parameter contains the nid, then replace/remove the nid on your parameter from your url.

Use this code on your Views: PHP

$url = token_replace('[current-page:url]');
$venue =$_GET['field_product_venue'];
if (strpos($venue, $row->nid) !== false) {
$change= str_replace($row->nid .',', '', $venue);
$l = l( t('DELETE'), $url,  array('query' => array('field_product_venue'=>$change)  ));
echo $l;    
| improve this answer | | | | |
  • Looks promising will try later. :D – Joshua Abellare Apr 21 '15 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.