drupal 6.x Felhasználó Profilokhoz 'radios' es 'checkboxes' field

eaposztrof képe

az /admin/user/profile oldalon alapertelmezettkent csak az alabbi mezok adhatoak hozza:

* egysoros szövegmező
* többsoros szövegmező
* jelölőnégyzet
* választólista
* szabad formátumú lista
* URL
* dátum

ezt kellene kiboviteni a 'checkboxes' es 'radios' mezokkel. ime a hack:

/modules/profile.module

<?php
function profile_help($path, $arg) {
  switch ($path) {
    case 'admin/help#profile':
      $output .= '<li>'. t('radio buttons') .'</li>';	//	hozzaadom a 'radio buttons' linket
      $output .= '<li>'. t('checkbox selection') .'</li>';	// hozzaadom a 'checkbox selection' linket
...
?>
<?php
  if (isset($user->{$field->name}) && $value = $user->{$field->name}) {
    switch ($field->type) {
      case 'radios':	//	megjelenitem az admin szamara 'radios' tipust
        return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
      case 'checkboxes':	//		megjelenitem az admin szamara 'checkboxes' tipust
        return $browse ? l($field->title, 'profile/'. $field->name) : check_plain($field->title);
...
?>
<?php
function profile_form_profile($edit, $user, $category, $register = FALSE) {
  $result = _profile_get_fields($category, $register);
  $weight = 1;
  $fields = array();
  while ($field = db_fetch_object($result)) {
    $category = $field->category;
    if (!isset($fields[$category])) {
      $fields[$category] = array('#type' => 'fieldset', '#title' => check_plain($category), '#weight' => $weight++);
    }
    switch ($field->type) {
      case 'textfield':
//    case 'url':	// ezt sort torlom
        $fields[$category][$field->name] = array('#type' => 'textfield',
          '#title' => check_plain($field->title),
          '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
          '#maxlength' => 255,
          '#description' => _profile_form_explanation($field),
          '#required' => $field->required,
        );
        if ($field->autocomplete) {
          $fields[$category][$field->name]['#autocomplete_path'] = "profile/autocomplete/". $field->fid;
        }
        break;
      case 'url':	//	ujra felveszem az 'url' tipus
        $fields[$category][$field->name] = array('#type' => 'textfield',
          '#title' => check_plain($field->title),
          '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : 'http://',	//	hozzaadom az alapertelmezett erteket: http://
          '#maxlength' => 255,
          '#description' => _profile_form_explanation($field),
          '#required' => $field->required,
        );
        break;
      case 'radios':	//	felveszem a 'radios' tipust
        $options = array();
        $lines = split("[,\n\r]", $field->options);
        foreach ($lines as $line) {
          if ($line = trim($line)) {
            $options[$line] = $line;
          }
        }
        $fields[$category][$field->name] = array('#type' => 'radios',
          '#title' => check_plain($field->title),
          '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
          '#options' => $options,
          '#description' => _profile_form_explanation($field),
          '#required' => $field->required,
        );
        break;
      case 'checkboxes':	//	felveszem a 'checkboxes' tipust
        $options = array();
        $lines = split("[,\n\r]", $field->options);
        foreach ($lines as $line) {
          if ($line = trim($line)) {
            $options[$line] = $line;
          }
        }
        $fields[$category][$field->name] = array('#type' => 'checkboxes',
          '#title' => check_plain($field->title),
          '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
          '#options' => $options,
          '#description' => _profile_form_explanation($field),
          '#required' => $field->required,
        );
        break;
...
?>
<?php
function _profile_field_types($type = NULL) {
  $types = array('radios' => t('radio buttons'),
                 'checkboxes' => t('checkbox selection'),
...
?>
thamas képe

Szerintem küldd be a drupal.org-on a profile modul issue trackerébe patch-ként (mármint, ha ez a kód működik és megoldja az általad felvetett problémát).

0
0

Üdvözlettel:
Hajas Tamás

eaposztrof képe

mukodik, es megoldja a problemat tokeletesen.. de fogalmam nincs hogy hogyan kell patcheket gyartani, en ctrl+c/ctrl+v -vel es php expert editorral szoktam patchelni ;)
de gyartani mar nem vagyok hajlando ezzel a modszerrel.. szivesen atpasszolom valakinek. GPL!
egeszsegetekre!

0
0

42

Nagy Gusztáv képe

Lehet, hogy én nem értek valamit, de a jelölőnégyzet az nem checkbox?

0
0

Nagy Gusztáv