0

Using the coding snippet below, how would I write the code to display the "Change" link only when the value in status is "A"?

I think i'm making this harder than it has to be, but the use of both drupal module structure and php are throwing me, since i am just learning module development.

The link showing in the array below appears at the end of each of my rows. I only want it to appear when the status equals "A".

Because this link is within this array, i can't figure out how and where to implement it. I just want an [if statement] like this:

if (drupal_render($form['status'][$key]['status']) == 'A',)
echo l(t('Change'), 'rooms/avail_room/' . $key . '/' . arg(1), array('attributes' => array('class' => 'room-stat-avail'))),
else{
echo "";
}

so when the html table is displayed, the 'Change' link will only appear in the last column when the value of status is "A"

Can't believe I got the module working, but can't turn this link on/off as i want. See code snippet below:

function team_room_available_form($form) {
    $output = "No space available.";

  if ($form['roomid']) {
    foreach (element_children($form['roomid']) as $key) {
      $rows[] = array(
        'data' => array(
          drupal_render($form[''][$key]),
          drupal_render($form['room_title'][$key]),
          drupal_render($form['username'][$key]),
          drupal_render($form['status'][$key]['status']),
          l(t('Change'), 'rooms/avail_room/' . $key . '/' . arg(1), array('attributes' => array('class' => 'room-stat-avail'))),
        ),
        'class' => $form['status'][$key]['#value'],
      );
    }
0

You can use below code snippets:

$field = $form['status'][$key]['status'];

if (strip_tags($field) == 'A') 
echo l(t('Change'), 'rooms/avail_room/' . $key . '/' . arg(1), array('attributes' => array('class' => 'room-stat-avail'))),
else{
echo "";
}

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.