=pod ---++ _restUpdateformfield This REST function is used to update a single form field of a specified topic. * =$session= - The TWiki object associated to this session * =$topic= - Name of the topic to be changed (this parameter is defined by the REST script * =$fieldname= - Name (key) of the form field to be changed * =$newval= - Value to be applied to the form field The function checks for edit autharization on the topic, so username and password parameters should be passed to the REST script! =cut sub _restUpdateformfield { my ($session) = @_; my $web; my $topic = TWiki::Func::getCgiQuery()->param('topic'); my $fieldname = TWiki::Func::getCgiQuery()->param('fieldname'); my $newval = TWiki::Func::getCgiQuery()->param('newval'); ($web, $topic) = TWiki::Func::normalizeWebTopicName(undef, $topic); unless ( TWiki::Func::topicExists ( $web, $topic )) { return "invalid Topic $web $topic\n"; } # check accessrights in topic unless (TWiki::Func::checkAccessPermission( 'EDIT', TWiki::Func::getWikiName(), undef, $topic, $web)) { my $error = "Access denied"; print CGI::header(-status => 401); print $error; print STDERR $error; return undef; } # get topic content my ($meta, $text) = TWiki::Func::readTopic($web, $topic); # get chosen form field my $field = $meta->get('FIELD', $fieldname ); # my $oldval = $field->{value}; $meta->putKeyed( 'FIELD', { name => $fieldname, value => $newval } ); my $error = TWiki::Func::saveTopic( $web, $topic, $meta, $text, { forcenewrevision => 1 } ); # $field = $meta->get('FIELD', '$fieldname'); # my $val = $field->{value}; # return "$oldval => $newval => $val : $error"; return undef; }