Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By gge on
I'm trying to build this:
<a href="/en/webform?edit[submitted][nameofthepet_webform_fieldset][webform_nume_animal_comp]=NAME-OF-PET" class="btn btn-primary btn-xs">Adopt NAME-OF-PET</a>
the code I'm using:
$adopt_me_link_male = l(t("Adopt !name",
array('!name' => $node->field_pet_name['und'][0]['safe_value']), array('context' => 'Male pet name')), 'node/163', array('query' => array('edit[submitted][nameofthepet_webform_fieldset][webform_nume_animal_comp]=' => $node->field_pet_name['und'][0]['safe_value'])), array('attributes' => array('class' => array('btn', 'btn-primary', 'btn-xs'),),) );
The above code generates the link but I have two problems:
1. the link looks like this:
<a href="/en/webform?edit%5Bsubmitted%5D%5Bnameofthepet_webform_fieldset%5D%5Bwebform_nume_animal_comp%5D%3D=NAME-OF-PET">Adopt NAME-OF-PET</a>
2. there's no css class applied to the anchor
Why the classes are not applied and the link looks so messy?
Thank you!
Comments
=-=
The question is better suited to the 'Module development and code questions' forum. Please edit the opening post and move it.Thanks.I think you want this:
I think you want this:
You had your attributes embedded in an unnecessary array. This is why it's often better to write out your long link codes as above, to make it easier to see what is happening.
Thank you very much. That's
Thank you very much. That's exactly what I needed :)
Hm... http://drupal
Hm... http://drupal.stackexchange.com/a/152023/1899
What's new and changing in PHP 8