Changeset 362


Ignore:
Timestamp:
08/17/09 05:33:11 (15 years ago)
Author:
nanardon
Message:
  • try to set only writable attributes since we strictly check the query
  • use field display value instead return value to fetch ajax data
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r272 r362  
    202202            ); 
    203203            $html .= q{<DIV ID="testdiv1" STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>}; 
    204             $html .= qq{ 
     204            $html .= qq| 
    205205            <A HREF="#" 
    206206                onClick="cal13.select(document.forms[0].$htmlname,'${htmlname}_anc','dd/MM/yyyy');return false;" 
    207207                TITLE="cal13.select(document.forms[0].$htmlname,'${htmlname}_anc','dd/MM/yyyy');return false;" 
    208208                NAME="${htmlname}_anc" ID="${htmlname}_anc"> 
    209                 <img src="} . $self->{c}->uri_for(qw(/static icons view-calendar-day.png)) 
    210                 . qq{" style="ref"></A>} . "\n"; 
     209                <img src="| . $self->{c}->uri_for(qw(/static icons view-calendar-day.png)) 
     210                . qq{" style="ref"></A> 
     211                } . "\n"; 
    211212            return $html; 
    212213        }; 
     
    215216                $self->escape($htmlname), 
    216217                $self->attr_raw_value($attr) ? '  checked="yes"' : '' 
    217             ); 
     218            ) . sprintf('<input type="hidden" name="%s">', 
     219                $self->escape($htmlname)); 
    218220        }; 
    219221        /^select(-\w+)?:([^:]+)(?::(.*))?$/ and do { 
     
    221223            my $otype = $2; 
    222224            my $keyfield = $3; 
     225            my $observe_keyfield = $keyfield || 'displayName'; 
    223226            my $select = sprintf('<select id="%s" name="%s">', 
    224227                $self->escape($htmlname), 
     
    226229            $select .= '<option value="">--</option>' . "\n" if ($options =~ /N/); 
    227230            my $value = $self->attr_raw_value($attr) || ''; 
     231            my $initial_observed = ''; 
    228232            foreach my $id ($self->base->list_objects($otype)) { 
    229233                my $obj = $self->base->get_object($otype, $id) or next; 
     
    236240                ); 
    237241                $select .= "\n"; 
     242                $initial_observed = $obj->get_c_field($observe_keyfield) 
     243                    if($value eq $val); 
    238244            } 
    239245            $select .= "</select>\n"; 
     
    242248                url => $self->{c}->uri_for('/ajax', 'rawattr', $otype), 
    243249                frequency => 1, 
    244                 with   => "'attr=displayName&id='+value", 
     250                with   => "'attr=" . $observe_keyfield . 
     251                "&id='+element.options[element.selectedIndex].text", 
    245252            }) . 
    246             qq{<span id="${htmlname}_span"></span>}; 
     253            qq|<span id="${htmlname}_span">$initial_observed</span>|; 
    247254            return $select; 
    248255        }; 
     
    267274                } 
    268275            ) . 
    269             qq{<span style="display:none" id="${htmlname}_stat">Searching...</span>}; 
     276            qq|<span style="display:none" id="${htmlname}_stat">Searching...</span>|; 
    270277            } 
    271278            return $textf; 
     
    292299                ? ($self->{c}->req->param("$prefix$_") ? 1 : 0) 
    293300                : ($self->{c}->req->param("$prefix$_") || undef) 
    294         } $self->attributes 
     301        } grep { $self->base->get_field_name($self->otype, $_, 'w') } $self->attributes 
    295302    ) or return; 
    296303    $self->{object}->base->commit; 
Note: See TracChangeset for help on using the changeset viewer.