AnyEven...DataForm(3)

πŸ’– AnyEvent::XMPP::Ext::DataForm πŸ’–

okay so this is the AnyEven...DataForm(3) page from User Contributed Perl Documentation, aka the lore drop for AnyEvent::XMPP::Ext::DataForm. Bestie, it's giving structured-data royalty and we're here for it. πŸ‘‘


✨ NAME ✨

AnyEvent::XMPP::Ext::DataForm β€” XEP-0004 DataForm. That's the whole name section, and it ate. πŸ’…


🌸 SYNOPSIS 🌸

There is literally no synopsis text here, bestie β€” the source page leaves this section empty and lets the methods do the talking. Mysterious main character energy, honestly. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

This module represents a Data Form as specified in XEP-0004. That's the entire description, no cap. 🫢


πŸŽ€ METHODS πŸŽ€

  • new (%args) β€” yep, this is new with %args, and the page doesn't spill extra tea about it. Quiet luxury. πŸ’…
  • append_field ($field) β€” appends a field to the form, slay. The $field must have the structure described in "FIELD STRUCTURE" below; no improvising, bestie.
  • from_node ($node) β€” interprets the AnyEvent::XMPP::Node object in $node as a data form XML node and reads out the fields plus all associated information. And yes: $node must be the XML node of the <x xmlns='jabber:x:data'> tag. Keep that exact, iykyk. πŸ”₯
  • make_answer_form ($request_form) β€” initializes this form with default answers and other neccessary fields from $request_form, which must be of type AnyEvent::XMPP::Ext::DataForm or compatible. The result is a form with a copy of all fields that are not of type fixed. The fields will also have the default value copied over. The form type will be set to submit. The idea is: this creates a template answer form from $request_form. To strip out the unneccessary fields later you don't need call the clear_empty_fields method. Periodt. ✨
  • clear_empty_fields β€” removes all fields that have no values and options. Cleanup era. 🧚
  • remove_field ($field_or_var) β€” removes a field either by its unique name or by reference. $field_or_var can either be the unique name or the actual field hash reference you get from get_field or get_fields. Choose your fighter. πŸ’€
  • set_form_type ($type) β€” sets the type of the form, which must be one of:
form, submit, cancel, result

No other values, bestie. The list is the list. πŸ‘‘

  • form_type β€” returns the type of the form, which is one of the options described in set_form_type above, or undef if no type was yet set. Very demure, very mindful. 🌸
  • get_reported_fields β€” if this is a search result, this method returns more than one element here. The returned list consists of fields as described in "FIELD STRUCTURE", only that they lack values and options. See also the get_items method. Yes, that's literally the line. 🫢
  • get_items β€” if this form is a search result, this method returns the list of items of that search. An item is a array ref of fields (field structure is described in "FIELD STRUCTURE"). This method returns a list of items. Iconic search-result behaviour. πŸ”
  • get_fields β€” returns a list of fields. Each field has the structure as described in "FIELD STRUCTURE". No notes. πŸ’…
  • get_field ($var) β€” returns the field with the unique field name $var, or undef if no such field is in this form. Bestie is either there or she isn't. πŸ™ˆ
  • set_field_value ($var, $value) β€” sets the value of the field with the unique name $var. If the field supports multiple values, all values will be removed and only $value will be added; if $value is undefined, the field's value will be deleted. Dramatic but correct. 😭
  • add_field_value ($var, $value) β€” adds the $value to the field with the unique name $var. If the field doesn't support multiple values, this method has the same effect as set_field_value. Same vibe, different method name. ✨
  • to_simxml β€” converts the form to a data strcuture that you can pass as node argument to the simxml function which is documented in AnyEvent::XMPP::Util. Example call might be:
my $node = $form->to_simxml;
simxml ($w, defns => $node->{ns}, node => $node);
NOTE: The returned simxml node has the "dns" field set so that no prefixes are generated for the namespace it is in. Keep that note, bestie β€” it's important. 🫢
  • as_debug_string β€” returns a string that represents the form. Only for debugging purposes.
⚠️ Only for debugging purposes, bestie β€” do not make it your whole personality. πŸ’€

🌈 FIELD STRUCTURE 🌈

This is the exact shape a field is serving:

{
   label    => 'field label',
   type     => 'field type',
   var      => '(unique) field name'
   required => true or false value,
   values   => [
      'value text',
      ...
   ],
   options  => [
      ['option label', 'option text'],
      ...
   ]
}

For the semantics of all fields please consult XEP 0004. Go read the source, iykyk. πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

XEP 0004 β€” that's the reference, bestie. Go drink from the firehose. πŸ”₯


πŸ“ AUTHOR πŸ“

Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>". Author section ate and left no crumbs. πŸ‘‘


Copyright 2007, 2008 Robin Redeker, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Signed with perl v5.42.2, dated 2026-02-15, and still serving AnyEven...DataForm(3) realness. Bye bestie! 🫢✨

πŸ“¦ where this page comes from