/** * @Implement of framework_element_x() */ function framework_element_dd_form_checkbox($field, $form) { $output = ''; if (!empty($field['#options'])) { $id = $field['#attributes']['id']; $field['#attributes']['class'] .= ' ' . $id; foreach ($field['#options'] as $key => $data) { $output .= '<span class="checkbox inline form_checkbox_option" alt="' . $id . '"><input'; if (is_array($field['#value']) && in_array($key, $field['#value'])) { $output .= ' checked="checked"'; } $field['#attributes']['id'] = $id . '_' . $key; $att = $field['#attributes']; $att['class'] .= ' checkbox'; if (is_array($data)) { foreach ($data as $_key => $value) { if ($_key == 'data' || $_key == 'name') { $text = $value; } else { $att[$_key] = $value; } } } else { $text = $data; } $output .= ' value="' . $key . '" name="' . $field['#name'] . '[' . $key . ']" type="checkbox"'; $output .= dd_attributes($att) . '/><span class="option_label">' . $text . '</span></span>'; } } else { $output .= '<input'; if ($field['#value']) { $output .= ' checked="checked"'; } $output .= ' value="1" name="' . $field['#name'] . '" type="checkbox"' . dd_attributes($field['#attributes']) . '/>'; } return $output; }
/** * @Implement of framework_element_x() */ function framework_element_dd_form_radio($field, $form) { $output = ''; if (is_array($field['#options'])) { $id = $field['#attributes']['id']; if (!empty($field['#attributes']['class'])) { $field['#attributes']['class'] .= ' ' . $id; } else { $field['#attributes']['class'] = $id; } foreach ($field['#options'] as $key => $data) { $field['#attributes']['id'] = $id . '_' . $key; $att = $field['#attributes']; if (is_array($data)) { foreach ($data as $_key => $value) { if ($_key == 'data' || $_key == 'name') { $text = $value; } else { $att[$_key] = $value; } } } else { $text = $data; } $output .= '<label class="radio-inline radio_field_' . $field['#name'] . '"><span class="form_radio_field"><input'; if ((string) $field['#value'] == (string) $key) { $output .= ' checked="checked"'; } $output .= ' value="' . $key . '" name="' . $field['#name'] . '" type="radio"'; $output .= dd_attributes($att) . '/>'; $output .= '<span class="form_radio_text" title="' . strip_tags($text) . '">' . $text . '</span></span></label>'; } } else { $output .= '<label class="radio-inline radio_field_' . $field['#name'] . '"><span class="form_radio_field"><input'; if ($field['#value']) { $output .= ' checked="checked"'; } $output .= ' value="1" name="' . $field['#name'] . '" type="radio"' . dd_attributes($field['#attributes']); $output .= '/></span></label>'; } return $output; }