简体   繁体   中英

Altering the text after a checkbox using the Drupal Form Api

I got the following issue. A clients wants that the text after checkboxes are links to other pages and thus between ...

I have the following code:

$form['boxes_brands'] = array(
        '#type'=>'checkboxes',
        '#title'=>'<div id="title-container">Merken</div>',
        '#options'=>$brandArr,
        '#default_value'=>$_SESSION['filter_brands_cat'],           
    );

=> $brandArr is an array of brands.

I looked in the Form Api of Drupal but I did not find an option to do this. I could alter the values in $brandArr but of course that changes the value of the value attribuut of the input object too.

Using the prefix and suffix options won't do it either because I don't want the checkboxes in the tags too.

Is there a clean way to do this?

Thanks!

If you created the form with the UI, then you should be able to specify something like this in as the options and links would be rendered as links:

google|<a href="http://www.google.com">This is a link to google</a>
yahoo|<a href="http://www.yahoo.com">Yahoo</a>
bing|<a href="http://www.bing.com">Bing!</a>

See example: 选项标签为链接

Otherwise, you should be able to modify the $brandArr accordingly to create links in the label. Doing this should NOT change the value of the attribute as it should be a $value->$label associative array. You just need to change the $label not the $value .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM