HTML-FormFu-2.01000755001751001752 012331714662 12431 5ustar00carlcarl000000000000README100644001751001752 60412331714662 13352 0ustar00carlcarl000000000000HTML-FormFu-2.01 This archive contains the distribution HTML-FormFu, version 2.01: HTML Form Creation, Rendering and Validation Framework This software is copyright (c) 2013 by Carl Franks. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v5.015. Changes100644001751001752 6755712331714662 14051 0ustar00carlcarl000000000000HTML-FormFu-2.012.01 2014-05-05 - Avoid uninitialized warning 2.00 2014-04-11 - New layout() method for customizing output of fields. Any custom elements which override string() will likely need modified. - Deprecated: reverse_single() and reverse_multi() are deprecated, and warn when used. If the new layout() is used, and there is no simple way to replicate the behaviour, these methods will have no affect. - TT template files changed - update them if you use a local copy. Files updated: field New files: field_layout, field_layout_block, field_layout_checkboxgroup_field, field_layout_comment, field_layout_contentbutton_field, field_layout_errors, field_layout_field, field_layout_javascript, field_layout_label, field_layout_label_field, field_layout_label_text, field_layout_multi_field, field_layout_parser, field_layout_select_field, field_layout_textarea_field. Files deleted due to layout() changes: checkboxgroup_tag, content_button, errors, input, input_tag, label, label_element, multi, select_tag, textarea_tag Unused files deleted: checkboxgroup. - New Filter::ForceListValue addresses rt bug #90813 - render_label() and render_field() no longer require TT. Include render_label() in tests. - Fix typo in I18N::ja (Yusuke Watase). - Bundle our own (renamed) copy of MooseX::Attribute::Chained to avoid warnings under perl 5.19.x 1.00 2013-12-16 - TT template files changed - update them if you use a local copy. Template file 'label_tag' renamed to 'label_element' - old file can be deleted. 'field' file changed. New 'errors' file. - TT no longer listed as a prerequisite. If you use the TT files, you must add 'Template' to your own app's prereqs. - Element::reCAPTCHA and Constraint::reCAPTCHA moved out to separate distribution. - HTML::FormFu::MultiForm moved out to separate distribution. - auto_container_class(), auto_label_class(), auto_comment_class(), auto_container_error_class(), auto_container_per_error_class(), auto_error_class() no longer have default values. See "RESTORING LEGACY HTML CLASSES" in HTML::FormFu docs to restore previous behaviour. - auto_label_class() no longer adds class to container. auto_label_class() now adds class to label tag. new auto_container_label_class() adds class to container. See "RESTORING LEGACY HTML CLASSES" in HTML::FormFu docs to restore previous behaviour. - auto_comment_class() no longer adds class to both container and comment. auto_comment_class() now only adds class to comment tag. new auto_container_comment_class() adds class to container. See "RESTORING LEGACY HTML CLASSES" in HTML::FormFu docs to restore previous behaviour. - Bug fix: param_value() form method now matches documented behaviour - returns undef when field has errors. (Reported by Hailin Hu). - New Element::Email and Element::URL HTML5 input fields. - Role::Element::Input has new datalist_options(), datalist_values(), datalist_id() and auto_datalist_id() methods to support HTML5 datalists. auto_datalist_id() is an inherited accessor which can be set on the Form, MultiForm, or Block. - Form and Elements has new title() attribute short-cut. - Constraint::Regex has new anchored() accessor. - New Input attribute accessors: placeholder(), pattern(), autocomplete(). - New Input boolean attribute accessors: autofocus(), multiple(), required(). - New Field inherited accessors: auto_container_per_error_class(), auto_error_container_class(), auto_error_container_per_error_class(), error_tag(), error_container_tag - Constraints have new experimental method fetch_error_message(). - All field elements have new method error_filename(). - default_args() now supports 'Block', 'Field', 'Input' pseudo-elements, '|' alternatives, and '+' and '-' ancestor modifiers. - New Czech (cs) I18N translation by Jan Grmela. - mk_inherited_accessors() now also creates a *_no_inherit() method. - Experimental new roles() form method. - form methods start(), end() now respect render_method - no longer force use of tt templates. - Bug fix: del_attribute() on empty attribute no longer sets the attribute. - All attribute accessors generated with mk_attrs() now have *_loc variants. - form methods start(), end() now respect render_method - no longer force use of tt templates. - Tests now always require Test::Aggregate::Nested. Re-enable aggregate tests on Win32. Don't run all tests twice under both aggregate and t/ (doh!) 0.09010 2012-10-05 - Internal changes - all Repeatable/nested_name munging is moved out of HTML::FormFu::Element::Repeatable into individual constraints 0.09009 2012-09-29 - Make sure object can('checked') before calling checked() (colinnewell) - Updated Repeatable control to update id_field on DBIC::Unique if present - ComboBox new get_select_field_nested_name(), get_text_field_nested_name() accessors. - Fieldset new legend_attributes() method. - New form_error_message_class() method. - Constraint 'when' callback now receives $constraint as 2nd argument. 0.09007 2012-01-23 - bump MooseX::Attribute::Chained version 0.09006 2012-01-23 - fixed deprecation warnings of MX::Attribute::Chained (bricas) - Added placeholder attributes for types Text and Textarea with L10N support. - Added L10N support for 'prefix' attributes for types Date and DateTime. - Added 'attributes' support to types Date and DateTime. 0.09005 2011-09-06 - bump version of prereq CGI to 3.37 to make all tests pass 0.09004 2011-08-26 - skip aggregate.t on Win32 - no functional changes to HTML::FormFu 0.09003_02 2011-08-25 - disable Test::Aggregate on Win32 0.09003_01 2011-05-11 - using Test::Aggregate for the test suite if installed tests finish now in seconds instead of minutes 0.09003 2011-05-10 - fixed regression in Model::HashRef introduced in 0.09000 0.09002 2011-03-21 - Hopefully fix IO::Interactive dependency properly 0.09001 2011-03-31 - Fix IO::Interactive dependency 0.09000 2011-03-29 - Codebase changed to use Moose - massive internal changes - any custom Elements, Constraints, etc will require changes. See advice on mailing list: http://www.mail-archive.com/html-formfu@lists.scsys.co.uk/msg02325.html Or ask for help on the mailing list: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu - Bug fix: was a fatal error when a value was submitted for Label element (code called delete_nested_hash_value instead of deleted_nested_hash_key). - Bug fix: RT#65728 Filter::Split shouldn't return a value if no value was submitted. - Bug fix: Element::Date now uses default() in preference to default_natural(). RT#65727 - DateTime elements, minutes and seconds have new 'interval' option. - Now only delete submitted value if there's no other field on the form with the same name. - load_config_file(stem) now honours the include path order, to mimic TT behaviour. 0.08002 2010-09-22 - Incompatible Change: removed all previously deprecated methods. - Incompatible Change: HTML::FormFu::QueryType::Catalyst File uploads under Catalyst no longer have copy_to(), link_to() and catalyst_upload() methods - Deprecated passing multiple arguments to many methods, where they were being implicitly converted to a hash-ref or array-ref. A warning is now issued. - Fix: Constraint::Equal with not(1) set no longer sets an error when both field values are empty strings. - Fix: An empty block with nested_name set, containing Label elements and no other fields, was causing the block's nested_name to be added to $form->valid(). RT #54967 - Constraints that inherit from HTML::FormFu::Constraint::_others have a new 'other_siblings' option, which auto-generates the 'others' list. - Constraint 'when' condition now supports new 'fields' and 'any_field' options. - Bumped required version of DateTime to 0.54 - needed to pass tests under Test::More 0.96. 0.07003 2010-08-02 - Fix: Group element now escapes each items attributes, label_attributes and container attributes (based on by patch by Jeff Dairiki). - Fix: If using default_natural, use default_datetime_args{set_time_zone} if it's also set (Radek). - Filter::HTMLScrubber extra functionality. - Update _merge_hashes() so it can also merge arrays and hashes into a new array. This is necessary to allow default_args() to define a different ref-type than the element or processor which uses its values. - Update Element::reCAPTCHA tests after changes to Captcha::reCAPTHCA (bump dependency version). 0.07002 2010-06-24 - Fix: Use MRO::Compat before mro to support perl 5.8 - Fix: Date and ComboBox elements need to run deflators before trying to use any default value - reported by Matija Grabnar. - Overloading comparisons no longer assume both arguments are a blessed object - change needed for latest Test::More (Test-Simple-0.95_02) (RT#57747) - Change Element::Date to not use deprecated DateTime::Locale methods. - Bump DateTime::Locale and DateTime::Format::Strptime required versions as DateTime::Locale Changes file has no mention of when the methods we're now using were added. - Removed Regexp::Copy from prereqs. 0.07001 2010-05-16 - No changes - cpan indexer failed for last release 0.07000 2010-05-16 - Change of behaviour: default_args() values are now applied to any object inheriting from the specified type, rather than just an instance of that type. Old behaviour is still supported with a minor change, see docs for details. - (Daniel Hilton) - Change of behaviour: default_args() key/values are now applied in order of inheritance, rather than the random order returned by keys() - New reverse_single attribute for all field elements. New reverse_group attribute for Checkboxgroup and Radiogroup elements. (Ronald Kimball) - New default_datetime_args() method on Date and DateTime elements. - Element::DateTime now supports a 'second' select menu. - Allow empty string as default value for Date element. (Ronald Kimball) - Now use Clone instead of Storable (ntyni@iki.fi). - Change from Class::C3 to mro, to get built-in support in perl >= 5.9 - New Bulgarian translation (Kamen Naydenov). - Fix bad links and markup in POD. (Ronald Kimball) - Fix spelling errors in POD (Ansgar Burchardt) - Documented Element::Textarea cols() and rows() methods. - Bump Config::Any requirement to version 0.18 for YAML::XS support - Refactored ObjectUtil (Daniel Hilton) 0.06001 2010-01-08 - Fixed issue with Model::HashRef where form fields with an underscore and overlapping name (e.g. 'foo' and 'foo_bar') were causing problems - Fix test suite year issue. 0.06000 2009-12-10 - New get_parent() method that traverses the parent hierarchy, returning the first parent that matches the supplied options. - Date element, year menu now supports 'reverse' option to reverse order of year list. - patch from Ozum Eldogan. - New Element::Block method auto_block_id(). - New only_on_reps() method for constraints on fields within a Repeatable element. Causes the constraint to only be run if the field's repeatable_count() matches one of the set values. - New Repeatable::Any constraint. - Bugfix: after submission, group-type fields were getting the wrong value when multiple fields had the same name. - patch by Doug Orleans. - Bugfix: If a field in a Repeatable block had an error, all copies of that field were displaying the error. - report by Doug Orleans. - Repeatable elements inside a Repeatable element, now works without having nested_name set. - Performance fix: change all uses of eval() to check for array/hash-refs to Scalar::Util::reftype() instead. - Was causing a hit for group-type fields with large numbers of options. - initial patch by Steve Nolte. - Bump required version of Data::Visitor to 0.26 - Minor pod fixes. 0.05004 2009-12-02 - No changes - last release was built on Windows and didn't pass pause's indexer checks. 0.05003 2009-11-29 - Fix YAML test files for YAML::XS compatibility 0.05002 2009-11-25 - Fix handling of counter_name in nested-repeatables. - Element::reCAPTCHA new constraint_args() method to pass options to the automatically-created Constraint::reCAPTCHA. - Model::HashRef->create() now works with submitted input. - Kwalitee updates. (RT #47998) - Pod fixes. (RT #49120, #49114, #46363) 0.05001 2009-07-03 - get_field(s), get_element(s), get_all_elements() now support a Regex object for any conditional argument. - Model::Hashref now searches for Multi and Repeatable elements using the regexes qr/Multi/ and qr/Repeatable/ to all for custom/derived classes. - New $form->add_localize_object_from_class() method. - New Element::Label. - Bugfix: DateTime element, hour/minute select menus didn't display correct value when hour/minute value was less than 10, and $form->process() wasn't called after $form->model->default_values(). - Silence "undef value in string eq" warnings. 0.05000 2009-05-26 - Nested repeatable blocks now create field names such as 'foo_1.bar_1' rather than 'foo.bar_1_1', to assist client-side scripting. 0.04002 2009-05-08 - Incompatible Change: Element::Repeatable->repeat() now defaults to 1 instead of 0. This allows empty Repeatables. - Fix test failures on Win32. - During Element::Repeatable->process() call children's process() before $self->repeat(). - Support nested Repeatable elements. - Ensure plugins are correctly cloned. 0.04001 2009-04-15 - Fix handling of arguments to plugin(). - HTML::FormFu::Model::HashRef supports now empty repeatable elements. - vertically-aligned CSS example updated. 0.04000 2009-03-26 - Incompatible Change: plugins process() method is now run *after* elements' process() method. - Incompatible Change: Button element no longer sets retain_default(1) - now sets force_default(1). Fixes bug where multiple buttons with same name were getting the wrong value after being redisplayed after errors. - New pre_process() plugin method that runs at the same time as the old process() hook. - New Model::HashRef. - New inherited method locale() available on forms, blocks and fields. - New Element::Number. - New Deflators: FormatNumber, PathClassFile, Callback. - New Filter::FormatNumber. - New Inflator::Callback. - New Norwegian I18N translation. - Updated vertically-aligned CSS. - config_file_path() now supports a list of directories. - Checkboxgroup + Radiogroup elements others() method now supports 'container_attributes' hash-key - Constraint when() condition no longer demands a 'value' or 'values' key - if it's missing, the constraint will pass on any true value. - Bugfix: _Group elements - ensure 'empty_first' gets set before any 'options', 'values', 'value_range'. - Bugfixes for constraint attach_errors_to_base(), attach_errors_to_others(). - Bugfix: Repeatable blocks now correctly rename nested-names in constraints' others(). - Bugfix: Repeatable blocks now rename field names in constraints' when(). - Bugfix: Repeatable blocks now reparent fields' plugins. 0.03007 2008-12-08 - Remove Test::Aggregate - seeing test failures under perl 5.8.x 0.03006 2008-12-03 - New DateTime element. - New MinRange, MaxRange, File::MinSize, File::MaxSize constraints to provide more specific error messages. - New File::Size constraint methods: min_kilobyte(), max_kilobyte(), min_megabyte(), max_megabyte(). - New config_file_path() method, used by load_config_file() and load_config_filestem(). - New field_order() method for Date elements. - New I18N translations for Romanian, Russian, Ukranian. - New MultiForm system for multi-page forms (not yet documented, file upload tests skipped due to test problems on MS Win32). - Length, Range and File::Size constraints now pass min() and max() values as I18N args, for use in strings. - DependOn and Equal constraints now pass the root field label as I18N arg, for use in strings. - Checkbox + Radio elements now default to value(1). - Constraint when() method now works with nested_names(). - Using test aggregate to speed-up tests. 0.03005 2008-09-08 - New ComboBox element. - Don't use Pod::Help - some people were getting test failures. 0.03004 2008-09-03 - New reCAPTCHA element. - New pt_br (Brazilian Portuguese) translation from Daniel Nicoletti. - New load_config_filestem() method for loading config files without having to specify the file extension. - New html_formfu_dumpconf.pl script, for viewing config files structure. - Assorted optimizations, providing over 20% runtime speedup. - Radio element now inherits from Checkbox, to remove duplicated code. - Radiogroup element now inherits from Checkboxgroup, to remove duplicated code. - checkboxgroup_tag template file has been removed - Checkboxgroup now just uses radiogroup_tag file. - All non-english I18N packages now correctly "use utf8;" - load_config_file() now switches on Config-General's UTF8, so that files are correctly decoded. - Regex filter now has an eval() method, which if true, eval's the contents of replace(), to allow the use of $1 variables or any other perl expression. - Allow languages() to be a single value, rather than just an arrayref. - CompoundJoin filter now ignores empty values. - examples/unicode updated. - Manual-Unicode cat. config examples changed to use MyApp->config(). - Stop warnings for undefined attributes - reported by Rod Taylor. - Documentation improvements by Ansgar Burchardt. 0.03003 2008-08-21 - Form and elements inside template files now have access to original object via self.object - Having a named Multi block within a Block with nested_name set, now works. - New Element method is_block() which is true for Block elements. - Multi no longers sets is_field(0) - it's now true for both is_field() and is_block(). - prereqs - set minimum version of Exporter.pm that exports import() 0.03002 2008-08-11 - Deprecate element_defaults() method. - New default_args() method. - New CompoundSprintf filter. - New DateTime constraint. - New field method default_empty_value(). - New I18N translations for Danish, French and Italian. - Added time_zone support to Inflator::DateTime - Documented that process() must be called before render() - this has been the case since 0.03000. 0.03001 2008-06-20 - Require version 0.38 of DateTime, for string overloading support. 0.03000 2008-06-19 - Field container_tag() now defaults to 'div' rather than 'span' to provide better layout without CSS. - Multi block no longer sets container_tag() to 'span' - defaults to 'div'. - HTML::FormFu::Model::DBIC moved out into a separate distribution. - Models now accessed through new form method: model(), with accompanying methods: default_model() and model_config. - Deprecated form methods: model_class(), defaults_from_model(), save_to_model(). - Model methods renamed to: default_model(), default_values() and update(). - New model method: create(). - Deprecated element method: db(). - Bugfixes for perl 5.10.0 (missing imports). - Bugfix: insert_before() and insert_after() now check if the object is already a child, and if so, removes it first. Reported by Ferruccio Zamuner. - Bugfix: update() many_to_many multi-value fields where 'default_column' included the table name (or 'me.') failed. - Bugfix: make inflators work with multiple submitted values. - Bugfix for Bool constraint: use '?' quantifier, not '*'. - Bugfix in Email constraint: ensure Email::Valid->address() is called in scalar context. - New Split and CompoundJoin filters. - New CompoundDateTime inflator. - New CompoundSplit and CompoundDateTime deflators. - New Plugin system (see tests, not yet documented) and StashValid plugin. - New form methods: stash_valid(), params_ignore_underscore() and tmp_upload_dir(). - New method for _Group fields: empty_first_label(). - Multi->render_data() now builds itself before it's children, so that deflators on the Multi work. - insert_before() and insert_after() now first removes the object if it's already a child of the target. - Callback filter and transformers now receive $params as a 2nd argument. - _Group field options() now supports value_xml, value_loc, label_xml and label_loc args. - get_* methods (fields, elements, constraints, etc) now accept any valid method-name as a search parameter. - add default_natural() method to Date element, allowing the use of DateTime::Format::Natural to parse dates such as "today" or "yesterday". - when() method for Constraints can now accept a callback - Transformer callbacks now get $params as second argument (as Constraints aready were getting) - Form method add_valid() now expects a full nested-name. - auto_id() now translates "%n" into the full nested-name. - Add a END block to DBICTestLib that cleans up the t/test.db 0.02004 2008-02-22 - Incompatible Change: $upload->headers no longer returns a hashref, it now returns a HTTP::Headers object. Tests for $upload->headers->{'Content-Type'} changed to $upload->headers->content_type. Tests for $upload->headers->{'Content-Length'} changed to $upload->headers->content_length. - Catalyst upload object now provides basename(), copy_to(), link_to(), size(), tempname() and type() methods which delegate to the Catalyst::Request::Upload object. - The original Catalyst::Request::Upload objects can be retrived with the catalyst_upload() method. - CGI and CGI::Simple upload objects provide size() and type() methods. - New Constraints: File::Size, File::MIME and File. - 'Required' and other constraints now work with file uploads. - Spanish I18N added. - Support for DBIx::Class schema methods which don't correspond to a database column or relationship. - Fixed test failures due to hardcoded date element output expecting the year 2007. - Fixed circular references in upload objects. 0.02003 2007-12-20 - Bugfix for has-many rels in defaults_from_model() - Added Template.pm back into prereqs - Repeatable element, increment_field_names() is now true by default - Fixed javascript rendering in _Field 0.02002 2007-12-12 - Fixes required for perl 5.10.0 0.02001 2007-12-12 - Bugfix for save_to_model() in HTML::FormFu::Model::DBIC 0.02000 2007-12-12 - New HTML::FormFu::Model::DBIC module to replace DBIx::Class::HTML::FormFu - New Repeatable block element - New "nested" params support. Form and Block elements have a new nested_name() method. Field elements have new nested(), nested_name() and nested_names() methods. Doesn't require CGI::Expand or Catalyst::Plugin::NestedParams - Uses new "string" renderer by default - doesn't use template files, Generated markup still exactly the same, Set render_method("tt") to use the template files (old behaviour), render_class_args() renamed to tt_args(), Template files now installed into @INC path by File::ShareDir, INCLUDE_PATH no longer set by default - New Checkboxgroup element. Works much like Radiogroup, but with checkboxes - Support multiple yaml documents in a single file - calls populate() once for each document - Date element now uses names of the form "date_day" instead of "date.day", so as to not conflict with the new nested-params. This should only affect you if your client-side code (CSS, JS) references the field names - Group elements (Select, Radiogroup, Checkboxgroup) now support a 'label_loc' argument, to provide the item labels via localize() - *_loc() methods now accept an arrayref argument, to allowing setting in YAML config files - render() now returns a string, not an object. $form->render->start_form() must be changed to $form->start(), $form->render->end_form() must be changed to $form->end, $form->render->field('foo') must be changed to $form->get_field('foo'), $form->render->hidden_fields() must be changed to $form->hidden_fields() - Bugfix: OutputProcessor::Indent was indenting closing tag, when it's value was empty (RT 30239) - Bugfix: Objects were getting wrong parents during clone() and auto_fieldset() 0.01006 2007-10-23 - render_class_args->{INCLUDE_PATH} now defaults to 'root' if it's not set - previously was only set if the entire render_class_args hashref was empty - New StripWhitespace OutputProcessor - New CopyValue Filter - New Cookbook and Unicode manual pages - New unicode example Catalyst application - New portuguese I18N translation - Callback Filters, Constraints and Validators now accept a fully qualified subroutine name instead of a code-ref - Date element month names from DateTime::Locale are run through ucfirst - Documentation improvements - Bugfix: forced errors are now displayed 0.01005 2007-09-21 - New Indent "output processor" to pretty-print output - New force_default() method on fields - New when() method for all Constraints - Behaviour change for MinMaxFields Constraint 0.01004 2007-09-12 - New html_formfu_deploy.pl helper program - AutoSet Constraint now works with Select optgroups - Added vertically-aligned CSS example - Fix circular reference / memory leak - Documentations fixes / additions - require v0.7901 of DateTime::Format::Builder to fix memory leak 0.01003 2007-08-22 - Add missing prereq to Makefile.PL 0.01002 2007-08-22 - Fixed missing imports causing errors with perl 5.9.x 0.01001 2007-08-22 - First non-dev release - All Element names now follow CamelCase convention - Key format of I18N files changed - New Date element - Use Class::C3 instead of SUPER - Automatically set UTF-8 encoding on TT - Support for Template::Alloy instead of TT 0.01000_02 2007-07-02 - Updated templates in tt_files.pm - 0.01000_02 was out of date 0.01000_02 2007-07-02 - Added YAML::Syck to dependencies - Pod fix 0.01000_01 2007-06-29 - First CPAN dev release LICENSE100644001751001752 4365212331714662 13551 0ustar00carlcarl000000000000HTML-FormFu-2.01This software is copyright (c) 2013 by Carl Franks. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2013 by Carl Franks. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2013 by Carl Franks. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644001751001752 344412331714662 14163 0ustar00carlcarl000000000000HTML-FormFu-2.01name = HTML-FormFu author = Carl Franks license = Perl_5 copyright_holder = Carl Franks copyright_year = 2013 version = 2.01 [Prereqs] perl = 5.008001 ; this is the lowest version of Exporter I can identify that exports import() ; it's bundled with perl 5.83 ; version 5.567 that ships with perl 5.82 is no good Exporter = 5.57 Carp = 0 Class::MOP::Method = 0 Clone = 0.31 Config::Any = 0.18 ; 0.10 - supports multi-doc config files ; 0.18 - prefers YAML::XS for YAML Cwd = 0 Data::Visitor = 0.26 ; when it dumped Any::Moose for Moose Data::Visitor::Callback = 0 DateTime = 0.54 ; required for string overloading DateTime::Format::Strptime = 1.2000 DateTime::Format::Builder = 0.7901 ; fixes memory leaks DateTime::Format::Natural = 0 DateTime::Locale = 0.45 Email::Valid = 0 Encode = 0 Fatal = 0 File::Copy = 0 File::Find = 0 File::ShareDir = 0 File::Spec = 0 File::Temp = 0 Hash::Flatten = 0 HTML::Scrubber = 0 HTML::TokeParser::Simple = 3.14 HTTP::Headers = 1.64 IO::File = 0 List::MoreUtils = 0 List::Util = 0 Locale::Maketext = 0 Module::Pluggable = 0 Moose = 1.00 ; Reasonable default until we get test results Moose::Role = 0 Moose::Util = 0 MooseX::Aliases = 0 ; MooseX::Attribute::Chained = 1.0.1 ; we're currently using a forked copy to avoid 'deprecated' warnings Number::Format = 0 Readonly = 0 Regexp::Common = 0 Path::Class::File = 0 Scalar::Util = 0 Storable = 0 Task::Weaken = 0 ; to ensure Scalar::Util was built with weaken() YAML::XS = 0.32 [Prereqs / TestRequires] CGI = 3.37 ; for file POST tests POSIX = 0 Test::More = 0.92 Test::Aggregate::Nested = 0.371 Test::Exception = 0 [MetaNoIndex] directory = examples [Test::Perl::Critic] [PodCoverageTests] [PodSyntaxTests] [PkgVersion] [NextRelease] format = %v %{yyyy-MM-dd}d [Repository] [@Basic] META.yml100644001751001752 310312331714662 13760 0ustar00carlcarl000000000000HTML-FormFu-2.01--- abstract: 'HTML Form Creation, Rendering and Validation Framework' author: - 'Carl Franks ' build_requires: CGI: '3.37' POSIX: '0' Test::Aggregate::Nested: '0.371' Test::Exception: '0' Test::More: '0.92' configure_requires: ExtUtils::MakeMaker: '6.30' File::ShareDir::Install: '0.03' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.140640' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: HTML-FormFu no_index: directory: - examples requires: Carp: '0' Class::MOP::Method: '0' Clone: '0.31' Config::Any: '0.18' Cwd: '0' Data::Visitor: '0.26' Data::Visitor::Callback: '0' DateTime: '0.54' DateTime::Format::Builder: '0.7901' DateTime::Format::Natural: '0' DateTime::Format::Strptime: '1.2000' DateTime::Locale: '0.45' Email::Valid: '0' Encode: '0' Exporter: '5.57' Fatal: '0' File::Copy: '0' File::Find: '0' File::ShareDir: '0' File::Spec: '0' File::Temp: '0' HTML::Scrubber: '0' HTML::TokeParser::Simple: '3.14' HTTP::Headers: '1.64' Hash::Flatten: '0' IO::File: '0' List::MoreUtils: '0' List::Util: '0' Locale::Maketext: '0' Module::Pluggable: '0' Moose: '1.00' Moose::Role: '0' Moose::Util: '0' MooseX::Aliases: '0' Number::Format: '0' Path::Class::File: '0' Readonly: '0' Regexp::Common: '0' Scalar::Util: '0' Storable: '0' Task::Weaken: '0' YAML::XS: '0.32' perl: '5.008001' resources: repository: git://github.com/fireartist/HTML-FormFu.git version: '2.01' MANIFEST100644001751001752 10021112331714662 13676 0ustar00carlcarl000000000000HTML-FormFu-2.01# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.015. Changes LICENSE MANIFEST MANIFEST.SKIP META.yml Makefile.PL README bin/html_formfu_deploy.pl bin/html_formfu_dumpconf.pl dist.ini examples/unicode/Changes examples/unicode/Makefile.PL examples/unicode/README examples/unicode/database.sql examples/unicode/lib/unicode.pm examples/unicode/lib/unicode/Controller/Root.pm examples/unicode/lib/unicode/Model/DB.pm examples/unicode/lib/unicode/Schema.pm examples/unicode/lib/unicode/Schema/Unicode.pm examples/unicode/lib/unicode/View/TT.pm examples/unicode/lib/unicode/View/TT/Alloy.pm examples/unicode/root/favicon.ico examples/unicode/root/formfu/block examples/unicode/root/formfu/checkboxgroup examples/unicode/root/formfu/checkboxgroup_tag examples/unicode/root/formfu/content_button examples/unicode/root/formfu/end_block examples/unicode/root/formfu/end_form examples/unicode/root/formfu/field examples/unicode/root/formfu/form examples/unicode/root/formfu/input examples/unicode/root/formfu/input_tag examples/unicode/root/formfu/label examples/unicode/root/formfu/multi examples/unicode/root/formfu/non_block examples/unicode/root/formfu/recaptcha examples/unicode/root/formfu/repeatable examples/unicode/root/formfu/select_tag examples/unicode/root/formfu/start_block examples/unicode/root/formfu/start_form examples/unicode/root/formfu/textarea_tag examples/unicode/root/forms/index.yml examples/unicode/root/forms/view.conf examples/unicode/root/forms/view.yml examples/unicode/root/index.tt examples/unicode/root/static/images/btn_120x50_built.png examples/unicode/root/static/images/btn_120x50_built_shadow.png examples/unicode/root/static/images/btn_120x50_powered.png examples/unicode/root/static/images/btn_120x50_powered_shadow.png examples/unicode/root/static/images/btn_88x31_built.png examples/unicode/root/static/images/btn_88x31_built_shadow.png examples/unicode/root/static/images/btn_88x31_powered.png examples/unicode/root/static/images/btn_88x31_powered_shadow.png examples/unicode/root/static/images/catalyst_logo.png examples/unicode/root/vertically-aligned.css examples/unicode/root/view.tt examples/unicode/script/unicode_cgi.pl examples/unicode/script/unicode_create.pl examples/unicode/script/unicode_fastcgi.pl examples/unicode/script/unicode_server.pl examples/unicode/script/unicode_test.pl examples/unicode/t/01app.t examples/unicode/t/02pod.t examples/unicode/t/03podcoverage.t examples/unicode/t/model_DB.t examples/unicode/t/view_TT-Alloy.t examples/unicode/t/view_TT.t examples/unicode/unicode.db examples/unicode/unicode.yml examples/vertically-aligned-css/test.jpg examples/vertically-aligned-css/vertically-aligned-ie.css examples/vertically-aligned-css/vertically-aligned.css examples/vertically-aligned-css/vertically-aligned.html examples/vertically-aligned-css/vertically-aligned.pl examples/vertically-aligned-css/vertically-aligned.tt examples/vertically-aligned-css/vertically-aligned.yml lib/HTML/FormFu.pm lib/HTML/FormFu/Attribute.pm lib/HTML/FormFu/Constants.pm lib/HTML/FormFu/Constraint.pm lib/HTML/FormFu/Constraint/ASCII.pm lib/HTML/FormFu/Constraint/AllOrNone.pm lib/HTML/FormFu/Constraint/AutoSet.pm lib/HTML/FormFu/Constraint/Bool.pm lib/HTML/FormFu/Constraint/Callback.pm lib/HTML/FormFu/Constraint/CallbackOnce.pm lib/HTML/FormFu/Constraint/DateTime.pm lib/HTML/FormFu/Constraint/DependOn.pm lib/HTML/FormFu/Constraint/Email.pm lib/HTML/FormFu/Constraint/Equal.pm lib/HTML/FormFu/Constraint/File.pm lib/HTML/FormFu/Constraint/File/MIME.pm lib/HTML/FormFu/Constraint/File/MaxSize.pm lib/HTML/FormFu/Constraint/File/MinSize.pm lib/HTML/FormFu/Constraint/File/Size.pm lib/HTML/FormFu/Constraint/Integer.pm lib/HTML/FormFu/Constraint/Length.pm lib/HTML/FormFu/Constraint/MaxLength.pm lib/HTML/FormFu/Constraint/MaxRange.pm lib/HTML/FormFu/Constraint/MinLength.pm lib/HTML/FormFu/Constraint/MinMaxFields.pm lib/HTML/FormFu/Constraint/MinRange.pm lib/HTML/FormFu/Constraint/Number.pm lib/HTML/FormFu/Constraint/Printable.pm lib/HTML/FormFu/Constraint/Range.pm lib/HTML/FormFu/Constraint/Regex.pm lib/HTML/FormFu/Constraint/Repeatable/Any.pm lib/HTML/FormFu/Constraint/Required.pm lib/HTML/FormFu/Constraint/Set.pm lib/HTML/FormFu/Constraint/SingleValue.pm lib/HTML/FormFu/Constraint/Word.pm lib/HTML/FormFu/Deflator.pm lib/HTML/FormFu/Deflator/Callback.pm lib/HTML/FormFu/Deflator/CompoundDateTime.pm lib/HTML/FormFu/Deflator/CompoundSplit.pm lib/HTML/FormFu/Deflator/FormatNumber.pm lib/HTML/FormFu/Deflator/PathClassFile.pm lib/HTML/FormFu/Deflator/Strftime.pm lib/HTML/FormFu/Deploy.pm lib/HTML/FormFu/Element.pm lib/HTML/FormFu/Element/Blank.pm lib/HTML/FormFu/Element/Block.pm lib/HTML/FormFu/Element/Button.pm lib/HTML/FormFu/Element/Checkbox.pm lib/HTML/FormFu/Element/Checkboxgroup.pm lib/HTML/FormFu/Element/ComboBox.pm lib/HTML/FormFu/Element/ContentButton.pm lib/HTML/FormFu/Element/Date.pm lib/HTML/FormFu/Element/DateTime.pm lib/HTML/FormFu/Element/Email.pm lib/HTML/FormFu/Element/Fieldset.pm lib/HTML/FormFu/Element/File.pm lib/HTML/FormFu/Element/Hidden.pm lib/HTML/FormFu/Element/Hr.pm lib/HTML/FormFu/Element/Image.pm lib/HTML/FormFu/Element/Label.pm lib/HTML/FormFu/Element/Multi.pm lib/HTML/FormFu/Element/Number.pm lib/HTML/FormFu/Element/Password.pm lib/HTML/FormFu/Element/Radio.pm lib/HTML/FormFu/Element/Radiogroup.pm lib/HTML/FormFu/Element/Repeatable.pm lib/HTML/FormFu/Element/Reset.pm lib/HTML/FormFu/Element/Select.pm lib/HTML/FormFu/Element/SimpleTable.pm lib/HTML/FormFu/Element/Src.pm lib/HTML/FormFu/Element/Submit.pm lib/HTML/FormFu/Element/Text.pm lib/HTML/FormFu/Element/Textarea.pm lib/HTML/FormFu/Element/URL.pm lib/HTML/FormFu/Exception.pm lib/HTML/FormFu/Exception/Constraint.pm lib/HTML/FormFu/Exception/Inflator.pm lib/HTML/FormFu/Exception/Input.pm lib/HTML/FormFu/Exception/Transformer.pm lib/HTML/FormFu/Exception/Validator.pm lib/HTML/FormFu/FakeQuery.pm lib/HTML/FormFu/Filter.pm lib/HTML/FormFu/Filter/Callback.pm lib/HTML/FormFu/Filter/CompoundJoin.pm lib/HTML/FormFu/Filter/CompoundSprintf.pm lib/HTML/FormFu/Filter/CopyValue.pm lib/HTML/FormFu/Filter/Encode.pm lib/HTML/FormFu/Filter/ForceListValue.pm lib/HTML/FormFu/Filter/FormatNumber.pm lib/HTML/FormFu/Filter/HTMLEscape.pm lib/HTML/FormFu/Filter/HTMLScrubber.pm lib/HTML/FormFu/Filter/LowerCase.pm lib/HTML/FormFu/Filter/NonNumeric.pm lib/HTML/FormFu/Filter/Regex.pm lib/HTML/FormFu/Filter/Split.pm lib/HTML/FormFu/Filter/TrimEdges.pm lib/HTML/FormFu/Filter/UpperCase.pm lib/HTML/FormFu/Filter/Whitespace.pm lib/HTML/FormFu/I18N.pm lib/HTML/FormFu/I18N/bg.pm lib/HTML/FormFu/I18N/cs.pm lib/HTML/FormFu/I18N/da.pm lib/HTML/FormFu/I18N/de.pm lib/HTML/FormFu/I18N/en.pm lib/HTML/FormFu/I18N/es.pm lib/HTML/FormFu/I18N/fr.pm lib/HTML/FormFu/I18N/hu.pm lib/HTML/FormFu/I18N/it.pm lib/HTML/FormFu/I18N/ja.pm lib/HTML/FormFu/I18N/no.pm lib/HTML/FormFu/I18N/pt_br.pm lib/HTML/FormFu/I18N/pt_pt.pm lib/HTML/FormFu/I18N/ro.pm lib/HTML/FormFu/I18N/ru.pm lib/HTML/FormFu/I18N/ua.pm lib/HTML/FormFu/I18N/zh_cn.pm lib/HTML/FormFu/Inflator.pm lib/HTML/FormFu/Inflator/Callback.pm lib/HTML/FormFu/Inflator/CompoundDateTime.pm lib/HTML/FormFu/Inflator/DateTime.pm lib/HTML/FormFu/Literal.pm lib/HTML/FormFu/Localize.pm lib/HTML/FormFu/Manual/Cookbook.pod lib/HTML/FormFu/Manual/Unicode.pod lib/HTML/FormFu/Model.pm lib/HTML/FormFu/Model/HashRef.pm lib/HTML/FormFu/ObjectUtil.pm lib/HTML/FormFu/OutputProcessor.pm lib/HTML/FormFu/OutputProcessor/Indent.pm lib/HTML/FormFu/OutputProcessor/StripWhitespace.pm lib/HTML/FormFu/Plugin.pm lib/HTML/FormFu/Plugin/StashValid.pm lib/HTML/FormFu/Preload.pm lib/HTML/FormFu/Processor.pm lib/HTML/FormFu/QueryType/CGI.pm lib/HTML/FormFu/QueryType/CGI/Simple.pm lib/HTML/FormFu/QueryType/Catalyst.pm lib/HTML/FormFu/Role/Constraint/Others.pm lib/HTML/FormFu/Role/ContainsElements.pm lib/HTML/FormFu/Role/ContainsElementsSharedWithField.pm lib/HTML/FormFu/Role/CreateChildren.pm lib/HTML/FormFu/Role/CustomRoles.pm lib/HTML/FormFu/Role/Element/Coercible.pm lib/HTML/FormFu/Role/Element/Field.pm lib/HTML/FormFu/Role/Element/FieldMethods.pm lib/HTML/FormFu/Role/Element/Group.pm lib/HTML/FormFu/Role/Element/Input.pm lib/HTML/FormFu/Role/Element/Layout.pm lib/HTML/FormFu/Role/Element/MultiElement.pm lib/HTML/FormFu/Role/Element/NonBlock.pm lib/HTML/FormFu/Role/Element/ProcessOptionsFromModel.pm lib/HTML/FormFu/Role/Element/SingleValueField.pm lib/HTML/FormFu/Role/Filter/Compound.pm lib/HTML/FormFu/Role/FormAndBlockMethods.pm lib/HTML/FormFu/Role/FormAndElementMethods.pm lib/HTML/FormFu/Role/FormBlockAndFieldMethods.pm lib/HTML/FormFu/Role/GetProcessors.pm lib/HTML/FormFu/Role/HasParent.pm lib/HTML/FormFu/Role/NestedHashUtils.pm lib/HTML/FormFu/Role/Populate.pm lib/HTML/FormFu/Role/Render.pm lib/HTML/FormFu/Transformer.pm lib/HTML/FormFu/Transformer/Callback.pm lib/HTML/FormFu/Upload.pm lib/HTML/FormFu/UploadParam.pm lib/HTML/FormFu/Util.pm lib/HTML/FormFu/Validator.pm lib/HTML/FormFu/Validator/Callback.pm lib/MooseX/Attribute/FormFuChained.pm lib/MooseX/FormFuChainedAccessors.pm lib/MooseX/Traits/Attribute/FormFuChained.pm share/templates/tt/xhtml/block share/templates/tt/xhtml/end_block share/templates/tt/xhtml/end_form share/templates/tt/xhtml/field share/templates/tt/xhtml/field_layout share/templates/tt/xhtml/field_layout_block share/templates/tt/xhtml/field_layout_checkboxgroup_field share/templates/tt/xhtml/field_layout_comment share/templates/tt/xhtml/field_layout_contentbutton_field share/templates/tt/xhtml/field_layout_errors share/templates/tt/xhtml/field_layout_field share/templates/tt/xhtml/field_layout_javascript share/templates/tt/xhtml/field_layout_label share/templates/tt/xhtml/field_layout_label_field share/templates/tt/xhtml/field_layout_label_text share/templates/tt/xhtml/field_layout_multi_field share/templates/tt/xhtml/field_layout_parser share/templates/tt/xhtml/field_layout_select_field share/templates/tt/xhtml/field_layout_textarea_field share/templates/tt/xhtml/form share/templates/tt/xhtml/non_block share/templates/tt/xhtml/recaptcha share/templates/tt/xhtml/repeatable share/templates/tt/xhtml/start_block share/templates/tt/xhtml/start_form t-aggregate/01use.t t-aggregate/04basic.t t-aggregate/04basic.yml t-aggregate/05_repeated_render.t t-aggregate/block_insert_after.t t-aggregate/block_insert_before.t t-aggregate/bugs/constructor_arg_overwrites_default.t t-aggregate/bugs/date_element_deflator.t t-aggregate/bugs/date_element_empty_input.t t-aggregate/bugs/datetime_hour_lt_10.t t-aggregate/bugs/disabled_select_default_value.yml t-aggregate/bugs/element_class.t t-aggregate/bugs/element_parent.t t-aggregate/bugs/empty_block_with_nested_name.t t-aggregate/bugs/empty_block_with_nested_name.yml t-aggregate/bugs/error_msg.t t-aggregate/bugs/error_multiple_fields_same_name.t t-aggregate/bugs/error_multiple_fields_same_name.yml t-aggregate/bugs/field_no_name.t t-aggregate/bugs/filter_run_once.t t-aggregate/bugs/multiple_checkbox_same_name.t t-aggregate/bugs/multiple_checkbox_same_name.yml t-aggregate/bugs/name_regex_chars.t t-aggregate/bugs/not_nested.t t-aggregate/bugs/populate_element_coderef.t t-aggregate/bugs/pre_1_00_compat.t t-aggregate/bugs/pre_1_00_compat.yml t-aggregate/bugs/render_processed_value_retain_default.t t-aggregate/bugs/render_processed_value_retain_default.yml t-aggregate/bugs/repeatable_increase_rep.t t-aggregate/bugs/repeatable_increase_rep.yml t-aggregate/bugs/result_params_multiple.t t-aggregate/bugs/select_empty_options.t t-aggregate/bugs/submit_no_value.t t-aggregate/bugs/submit_retain_default.t t-aggregate/bugs/value_empty_string.t t-aggregate/bugs/value_no_default.t t-aggregate/bugs/yaml_utf8.t t-aggregate/bugs/yaml_utf8.txt t-aggregate/bugs/yaml_utf8.yml t-aggregate/constraints/allornone.t t-aggregate/constraints/allornone_attach_errors_to_base.t t-aggregate/constraints/allornone_attach_errors_to_base.yml t-aggregate/constraints/allornone_attach_errors_to_others.t t-aggregate/constraints/allornone_attach_errors_to_others.yml t-aggregate/constraints/ascii.t t-aggregate/constraints/autoset.t t-aggregate/constraints/autoset_group.t t-aggregate/constraints/bool.t t-aggregate/constraints/callback.t t-aggregate/constraints/callbackonce.t t-aggregate/constraints/constraint.t t-aggregate/constraints/constraint_other_siblings.t t-aggregate/constraints/constraint_other_siblings.yml t-aggregate/constraints/constraint_other_siblings_not.t t-aggregate/constraints/constraint_other_siblings_not.yml t-aggregate/constraints/constraint_when.t t-aggregate/constraints/constraint_when.yml t-aggregate/constraints/constraint_when_any_field.t t-aggregate/constraints/constraint_when_any_field.yml t-aggregate/constraints/constraint_when_any_true_value.t t-aggregate/constraints/constraint_when_any_true_value.yml t-aggregate/constraints/constraint_when_default_empty_value.t t-aggregate/constraints/constraint_when_default_empty_value.yml t-aggregate/constraints/constraint_when_fields.t t-aggregate/constraints/constraint_when_fields.yml t-aggregate/constraints/datetime_parser.t t-aggregate/constraints/dependon.t t-aggregate/constraints/dependon_attach_errors_to_base.t t-aggregate/constraints/dependon_attach_errors_to_base.yml t-aggregate/constraints/dependon_attach_errors_to_others.t t-aggregate/constraints/dependon_attach_errors_to_others.yml t-aggregate/constraints/email.t t-aggregate/constraints/equal.t t-aggregate/constraints/equal_internals.t t-aggregate/constraints/equal_not.t t-aggregate/constraints/file.t t-aggregate/constraints/file.yml t-aggregate/constraints/file_maxsize.t t-aggregate/constraints/file_maxsize.yml t-aggregate/constraints/file_mime.t t-aggregate/constraints/file_mime.yml t-aggregate/constraints/file_minsize.t t-aggregate/constraints/file_minsize.yml t-aggregate/constraints/file_size.t t-aggregate/constraints/file_size.yml t-aggregate/constraints/integer.t t-aggregate/constraints/length.t t-aggregate/constraints/localize.t t-aggregate/constraints/maxlength.t t-aggregate/constraints/maxrange.t t-aggregate/constraints/minlength.t t-aggregate/constraints/minmaxfields.t t-aggregate/constraints/minmaxfields_with_filter_split.t t-aggregate/constraints/minmaxfields_with_filter_split.yml t-aggregate/constraints/minrange.t t-aggregate/constraints/not_equal.t t-aggregate/constraints/not_word.t t-aggregate/constraints/number.t t-aggregate/constraints/printable.t t-aggregate/constraints/range.t t-aggregate/constraints/regex.t t-aggregate/constraints/regex_anchored.t t-aggregate/constraints/regex_common.t t-aggregate/constraints/repeatable_any.t t-aggregate/constraints/repeatable_any.yml t-aggregate/constraints/repeatable_any_not_increment_field_names.t t-aggregate/constraints/repeatable_any_not_increment_field_names.yml t-aggregate/constraints/required.t t-aggregate/constraints/required_file.t t-aggregate/constraints/required_file.yml t-aggregate/constraints/required_only_on_reps.t t-aggregate/constraints/required_only_on_reps.yml t-aggregate/constraints/set.t t-aggregate/constraints/singlevalue.t t-aggregate/constraints/word.t t-aggregate/constraints/xml.t t-aggregate/deflators/callback.t t-aggregate/deflators/compounddatetime.t t-aggregate/deflators/compounddatetime.yml t-aggregate/deflators/compounddatetime_field_order.t t-aggregate/deflators/compounddatetime_field_order.yml t-aggregate/deflators/compoundsplit.t t-aggregate/deflators/compoundsplit.yml t-aggregate/deflators/compoundsplit_after_submit.t t-aggregate/deflators/compoundsplit_after_submit.yml t-aggregate/deflators/compoundsplit_field_order.t t-aggregate/deflators/compoundsplit_field_order.yml t-aggregate/deflators/compoundsplit_split.t t-aggregate/deflators/compoundsplit_split.yml t-aggregate/deflators/formatnumber.t t-aggregate/deflators/formatnumber.yml t-aggregate/deflators/pathclassfile.t t-aggregate/elements/blank.t t-aggregate/elements/block.t t-aggregate/elements/block_auto_block_id.t t-aggregate/elements/block_auto_block_id.yml t-aggregate/elements/block_repeatable.t t-aggregate/elements/block_repeatable.yml t-aggregate/elements/block_repeatable_attrs.t t-aggregate/elements/block_repeatable_attrs.yml t-aggregate/elements/block_repeatable_auto_block_id.t t-aggregate/elements/block_repeatable_auto_block_id.yml t-aggregate/elements/block_repeatable_auto_id.t t-aggregate/elements/block_repeatable_auto_id.yml t-aggregate/elements/block_repeatable_date.t t-aggregate/elements/block_repeatable_date.yml t-aggregate/elements/block_repeatable_inc.t t-aggregate/elements/block_repeatable_inc.yml t-aggregate/elements/block_repeatable_multi.t t-aggregate/elements/block_repeatable_tag.t t-aggregate/elements/block_repeatable_tag.yml t-aggregate/elements/button.t t-aggregate/elements/button_no_name.t t-aggregate/elements/checkbox.t t-aggregate/elements/checkbox_force_default.t t-aggregate/elements/checkbox_retain_default.t t-aggregate/elements/checkbox_reverse.t t-aggregate/elements/checkbox_reverse.yml t-aggregate/elements/checkboxgroup.t t-aggregate/elements/checkboxgroup_attributes_escaped.t t-aggregate/elements/checkboxgroup_attributes_escaped.yml t-aggregate/elements/combobox.t t-aggregate/elements/combobox.yml t-aggregate/elements/combobox_repeatable.t t-aggregate/elements/combobox_repeatable.yml t-aggregate/elements/combobox_required.t t-aggregate/elements/combobox_required.yml t-aggregate/elements/content_button.t t-aggregate/elements/date.t t-aggregate/elements/date_default.t t-aggregate/elements/date_default_datetime_args.t t-aggregate/elements/date_default_datetime_args.yml t-aggregate/elements/date_default_empty.t t-aggregate/elements/date_month_year.t t-aggregate/elements/date_natural.t t-aggregate/elements/date_order.t t-aggregate/elements/date_order_error.t t-aggregate/elements/date_rename.t t-aggregate/elements/date_undef.t t-aggregate/elements/date_year_reverse.t t-aggregate/elements/date_year_reverse.yml t-aggregate/elements/datetime.t t-aggregate/elements/datetime.yml t-aggregate/elements/datetime_interval.t t-aggregate/elements/datetime_interval.yml t-aggregate/elements/datetime_seconds.t t-aggregate/elements/datetime_seconds.yml t-aggregate/elements/element_setup.t t-aggregate/elements/email.t t-aggregate/elements/escaping.t t-aggregate/elements/field_default_empty_value.t t-aggregate/elements/field_non_param.t t-aggregate/elements/fieldset.t t-aggregate/elements/fieldset_legend_attrs.t t-aggregate/elements/fieldset_legend_attrs.yml t-aggregate/elements/file.t t-aggregate/elements/file_post.txt t-aggregate/elements/file_post_cgi_simple.t t-aggregate/elements/hidden.t t-aggregate/elements/hr.t t-aggregate/elements/image.t t-aggregate/elements/label.t t-aggregate/elements/label.yml t-aggregate/elements/label_value_submission.t t-aggregate/elements/label_value_submission.yml t-aggregate/elements/multi.t t-aggregate/elements/multi_errors.t t-aggregate/elements/multiple_submit_buttons.t t-aggregate/elements/no_block_tag.t t-aggregate/elements/no_block_tag.yml t-aggregate/elements/no_container_tag.t t-aggregate/elements/no_container_tag.yml t-aggregate/elements/number.t t-aggregate/elements/number.yml t-aggregate/elements/object.t t-aggregate/elements/object/field_layout_field_custom t-aggregate/elements/password.t t-aggregate/elements/password_render_value.t t-aggregate/elements/password_retain_default.t t-aggregate/elements/radio.t t-aggregate/elements/radio_force_default.t t-aggregate/elements/radio_retain_default.t t-aggregate/elements/radiogroup.t t-aggregate/elements/radiogroup_attributes_escaped.t t-aggregate/elements/radiogroup_attributes_escaped.yml t-aggregate/elements/radiogroup_attrs_xml.t t-aggregate/elements/radiogroup_dup_opt.t t-aggregate/elements/radiogroup_errors.t t-aggregate/elements/radiogroup_force_default.t t-aggregate/elements/radiogroup_id.t t-aggregate/elements/radiogroup_id_value.t t-aggregate/elements/radiogroup_retain_default.t t-aggregate/elements/radiogroup_subgroup.t t-aggregate/elements/radiogroup_unknown_opt.t t-aggregate/elements/radiogroup_xml.t t-aggregate/elements/render_method.t t-aggregate/elements/repeatable_counter_name.t t-aggregate/elements/repeatable_counter_name.yml t-aggregate/elements/repeatable_repeatable.t t-aggregate/elements/repeatable_repeatable.yml t-aggregate/elements/reset.t t-aggregate/elements/reverse.t t-aggregate/elements/select.t t-aggregate/elements/select_attributes_escaped.t t-aggregate/elements/select_attributes_escaped.yml t-aggregate/elements/select_deflator_default.t t-aggregate/elements/select_empty_first.t t-aggregate/elements/select_empty_first.yml t-aggregate/elements/select_empty_first_label.t t-aggregate/elements/select_force_default.t t-aggregate/elements/select_label_loc.t t-aggregate/elements/select_multi_default_values.t t-aggregate/elements/select_multi_value.t t-aggregate/elements/select_optgroup.t t-aggregate/elements/select_options.t t-aggregate/elements/select_retain_default.t t-aggregate/elements/select_same_name.t t-aggregate/elements/select_same_name.yml t-aggregate/elements/select_value_range.t t-aggregate/elements/simple_table.t t-aggregate/elements/simple_table.yml t-aggregate/elements/simple_table_class.t t-aggregate/elements/simple_table_class.yml t-aggregate/elements/simple_table_multiple.t t-aggregate/elements/simple_table_multiple.yml t-aggregate/elements/src.t t-aggregate/elements/submit.t t-aggregate/elements/text.t t-aggregate/elements/text_attributes.t t-aggregate/elements/text_auto_comment_class.t t-aggregate/elements/text_auto_comment_class.yml t-aggregate/elements/text_auto_container_class.t t-aggregate/elements/text_auto_container_class.yml t-aggregate/elements/text_auto_container_comment_class.t t-aggregate/elements/text_auto_container_comment_class.yml t-aggregate/elements/text_auto_container_error_class.t t-aggregate/elements/text_auto_container_error_class.yml t-aggregate/elements/text_auto_container_label_class.t t-aggregate/elements/text_auto_container_label_class.yml t-aggregate/elements/text_auto_label_class.t t-aggregate/elements/text_auto_label_class.yml t-aggregate/elements/text_datalist_options.t t-aggregate/elements/text_datalist_options.yml t-aggregate/elements/text_datalist_values.t t-aggregate/elements/text_datalist_values.yml t-aggregate/elements/text_errors.t t-aggregate/elements/text_force_default.t t-aggregate/elements/text_layout.t t-aggregate/elements/text_layout.yml t-aggregate/elements/text_retain_default.t t-aggregate/elements/text_title.t t-aggregate/elements/textarea.t t-aggregate/elements/url.t t-aggregate/elements/url.yml t-aggregate/examples/custom_label.t t-aggregate/examples/custom_label2.t t-aggregate/examples/field_as.t t-aggregate/examples/fields_as_list_items.t t-aggregate/field_accessor_loc.t t-aggregate/field_accessor_loc_arrayref.t t-aggregate/field_accessor_loc_arrayref.yml t-aggregate/field_change_name.t t-aggregate/field_id.t t-aggregate/filters/all_by_default.t t-aggregate/filters/callback.t t-aggregate/filters/compoundjoin.t t-aggregate/filters/compoundjoin.yml t-aggregate/filters/compoundjoin_field_order.t t-aggregate/filters/compoundjoin_field_order.yml t-aggregate/filters/compoundjoin_join.t t-aggregate/filters/compoundjoin_join.yml t-aggregate/filters/compoundsprintf.t t-aggregate/filters/compoundsprintf.yml t-aggregate/filters/compoundsprintf_field_order.t t-aggregate/filters/compoundsprintf_field_order.yml t-aggregate/filters/copyvalue.t t-aggregate/filters/encode.t t-aggregate/filters/filter.t t-aggregate/filters/formatnumber.t t-aggregate/filters/formatnumber.yml t-aggregate/filters/htmlescape.t t-aggregate/filters/htmlscrubber.t t-aggregate/filters/lowercase.t t-aggregate/filters/nonnumeric.t t-aggregate/filters/regex.t t-aggregate/filters/regex.yml t-aggregate/filters/regex_eval.t t-aggregate/filters/regex_eval.yml t-aggregate/filters/split.t t-aggregate/filters/split.yml t-aggregate/filters/trimedges.t t-aggregate/filters/uppercase.t t-aggregate/filters/whitespace.t t-aggregate/force_errors/allornone.t t-aggregate/force_errors/callbackonce.t t-aggregate/force_errors/dependon.t t-aggregate/force_errors/equal.t t-aggregate/force_errors/force_errors.t t-aggregate/force_errors/integer.t t-aggregate/force_errors/minmaxfields.t t-aggregate/form/add_render_class_args.t t-aggregate/form/add_valid.t t-aggregate/form/add_valid_unknown.t t-aggregate/form/attributes.t t-aggregate/form/auto_constraint_class.t t-aggregate/form/auto_error_class.t t-aggregate/form/auto_error_message.t t-aggregate/form/auto_fieldset.t t-aggregate/form/auto_label.t t-aggregate/form/clone.t t-aggregate/form/config_callback.t t-aggregate/form/config_callback.yml t-aggregate/form/constraints_from_dbic.t t-aggregate/form/constraints_from_dbic_rs.t t-aggregate/form/default_args.t t-aggregate/form/default_args_alt.t t-aggregate/form/default_args_alt.yml t-aggregate/form/default_args_isa.t t-aggregate/form/default_args_isa.yml t-aggregate/form/default_args_not_inheriting.t t-aggregate/form/default_values.t t-aggregate/form/end.t t-aggregate/form/error_message.t t-aggregate/form/force_error_message.t t-aggregate/form/form_error_message_class.t t-aggregate/form/get_all_elements.t t-aggregate/form/get_constraint.t t-aggregate/form/get_constraints.t t-aggregate/form/get_deflator.t t-aggregate/form/get_deflators.t t-aggregate/form/get_element.t t-aggregate/form/get_elements.t t-aggregate/form/get_errors.t t-aggregate/form/get_field.t t-aggregate/form/get_fields.t t-aggregate/form/get_filter.t t-aggregate/form/get_filters.t t-aggregate/form/get_inflator.t t-aggregate/form/get_inflators.t t-aggregate/form/get_parent.t t-aggregate/form/get_parent.yml t-aggregate/form/has_errors.t t-aggregate/form/hidden_fields.t t-aggregate/form/init_arg.t t-aggregate/form/insert_after.t t-aggregate/form/insert_before.t t-aggregate/form/javascript.t t-aggregate/form/javascript_src.t t-aggregate/form/languages.t t-aggregate/form/languages.yml t-aggregate/form/model.t t-aggregate/form/multiple_same_named_fields.t t-aggregate/form/object.t t-aggregate/form/object/form t-aggregate/form/param.t t-aggregate/form/param_array.t t-aggregate/form/param_list.t t-aggregate/form/param_value.t t-aggregate/form/params.t t-aggregate/form/params_ignore_underscore.t t-aggregate/form/query.t t-aggregate/form/render_processed_value.t t-aggregate/form/render_processed_value.yml t-aggregate/form/start.t t-aggregate/form/stash.t t-aggregate/form/submitted.t t-aggregate/form/submitted_and_valid.t t-aggregate/form/title_xml.t t-aggregate/form/valid.t t-aggregate/i18n/add_localize_object.t t-aggregate/i18n/add_localize_object_from_class.t t-aggregate/i18n/add_localize_object_from_class.yml t-aggregate/inflators/array.t t-aggregate/inflators/callback.t t-aggregate/inflators/compounddatetime.t t-aggregate/inflators/compounddatetime.yml t-aggregate/inflators/compounddatetime_field_order.t t-aggregate/inflators/compounddatetime_field_order.yml t-aggregate/inflators/datetime_optional.t t-aggregate/inflators/datetime_parser.t t-aggregate/inflators/datetime_regex.t t-aggregate/inflators/datetime_regex_string.t t-aggregate/inflators/datetime_strptime.t t-aggregate/inflators/datetime_timezone.t t-aggregate/inflators/datetime_with_constraint.t t-aggregate/inflators/datetime_with_constraint.yml t-aggregate/internals/default_args-types.t t-aggregate/internals/default_args-types.yml t-aggregate/load_config/config_file_path.t t-aggregate/load_config/config_file_path/form.yml t-aggregate/load_config/config_file_path2/form.yml t-aggregate/load_config/load_config_file.t t-aggregate/load_config/load_config_file_constraint_regex.t t-aggregate/load_config/load_config_file_constraint_regex.yml t-aggregate/load_config/load_config_file_fieldset.yml t-aggregate/load_config/load_config_file_form.yml t-aggregate/load_config/load_config_file_multi_stream.t t-aggregate/load_config/load_config_file_multi_stream.yml t-aggregate/load_config/load_config_file_multiple.t t-aggregate/load_config/load_config_file_multiple.yml t-aggregate/load_config/load_config_file_multiple1.yml t-aggregate/load_config/load_config_file_multiple2.yml t-aggregate/load_config/load_config_filestem.t t-aggregate/model/hashref_create.t t-aggregate/model/hashref_create_repeatable_without_nestedname.t t-aggregate/model/hashref_create_repeatable_without_nestedname.yml t-aggregate/model/hashref_default_values.t t-aggregate/model/hashref_escaping.t t-aggregate/model/hashref_multi_within_rep.t t-aggregate/model/hashref_multi_within_rep.yml t-aggregate/model/hashref_process.t t-aggregate/multiple_select_fields.t t-aggregate/multiple_text_fields.t t-aggregate/nested/constraints/allornone.t t-aggregate/nested/constraints/callbackonce.t t-aggregate/nested/constraints/constraint_when.t t-aggregate/nested/constraints/constraint_when.yml t-aggregate/nested/constraints/dependon.t t-aggregate/nested/constraints/equal.t t-aggregate/nested/constraints/minmaxfields.t t-aggregate/nested/constraints/required.t t-aggregate/nested/element_name.t t-aggregate/nested/element_name.yml t-aggregate/nested/elements/block_repeatable_multi_named.t t-aggregate/nested/elements/block_repeatable_multi_named.yml t-aggregate/nested/elements/block_repeatable_multi_named_filter.t t-aggregate/nested/elements/block_repeatable_multi_named_filter.yml t-aggregate/nested/elements/block_without_name.t t-aggregate/nested/elements/block_without_name.yml t-aggregate/nested/elements/checkbox_force_default.t t-aggregate/nested/elements/checkbox_retain_default.t t-aggregate/nested/elements/combobox.t t-aggregate/nested/elements/date.t t-aggregate/nested/elements/multi.t t-aggregate/nested/elements/multi_named.t t-aggregate/nested/elements/radio.t t-aggregate/nested/elements/radio_force_default.t t-aggregate/nested/elements/radio_retain_default.t t-aggregate/nested/elements/radiogroup.t t-aggregate/nested/elements/radiogroup_force_default.t t-aggregate/nested/elements/radiogroup_retain_default.t t-aggregate/nested/elements/repeatable_repeatable.t t-aggregate/nested/elements/repeatable_repeatable.yml t-aggregate/nested/elements/select.t t-aggregate/nested/elements/select_force_default.t t-aggregate/nested/elements/select_retain_default.t t-aggregate/nested/elements/select_same_name.t t-aggregate/nested/elements/select_same_name.yml t-aggregate/nested/elements/text.t t-aggregate/nested/filters/regex.t t-aggregate/nested/form/render_processed_value.t t-aggregate/nested/form/render_processed_value.yml t-aggregate/nested/form_input.t t-aggregate/nested/illegal_name.t t-aggregate/nested/inflators/datetime_strptime.t t-aggregate/nested/internals/form_processed_params.t t-aggregate/nested/internals/hash_keys.t t-aggregate/nested/param.t t-aggregate/nested/params.t t-aggregate/nested/pre_expanded.t t-aggregate/nested/transformers/callback.t t-aggregate/nested/valid.t t-aggregate/nested/validators/callback.t t-aggregate/output_processors/indent.t t-aggregate/output_processors/indent_internals.t t-aggregate/output_processors/strip_whitespace.t t-aggregate/output_processors/strip_whitespace.yml t-aggregate/plugins/stashvalid.t t-aggregate/plugins/stashvalid.yml t-aggregate/plugins/stashvalid_on_field.t t-aggregate/plugins/stashvalid_on_field.yml t-aggregate/repeatable/clone.t t-aggregate/repeatable/clone.yml t-aggregate/repeatable/constraints/attach_errors_to.t t-aggregate/repeatable/constraints/attach_errors_to.yml t-aggregate/repeatable/constraints/equal.t t-aggregate/repeatable/constraints/equal.yml t-aggregate/repeatable/constraints/required.t t-aggregate/repeatable/constraints/required.yml t-aggregate/repeatable/constraints/required_not_increment_field_names.t t-aggregate/repeatable/constraints/required_not_increment_field_names.yml t-aggregate/repeatable/constraints/required_not_nested.t t-aggregate/repeatable/constraints/required_not_nested.yml t-aggregate/repeatable/constraints/when.t t-aggregate/repeatable/constraints/when.yml t-aggregate/repeatable/repeatable/constraints/repeatable_any.t t-aggregate/repeatable/repeatable/constraints/repeatable_any.yml t-aggregate/roles/block.t t-aggregate/roles/block.yml t-aggregate/roles/field.t t-aggregate/roles/field.yml t-aggregate/roles/form.t t-aggregate/roles/form.yml t-aggregate/transformers/callback.t t-aggregate/utils/append_xml_attribute.t t-aggregate/utils/has_xml_attribute.t t-aggregate/utils/remove_xml_attribute.t t-aggregate/validators/callback.t t-aggregate/validators/validator.t t/aggregate.t t/elements-file_post.t t/elements-file_post.txt t/lib/HTMLFormFu/DBICUniqueFake.pm t/lib/HTMLFormFu/ElementSetup.pm t/lib/HTMLFormFu/I18N.pm t/lib/HTMLFormFu/I18N/en.pm t/lib/HTMLFormFu/MyBlockRole.pm t/lib/HTMLFormFu/MyDeflator.pm t/lib/HTMLFormFu/MyFieldRole.pm t/lib/HTMLFormFu/MyFormRole.pm t/lib/HTMLFormFu/MyModel.pm t/lib/HTMLFormFu/MyObject.pm t/lib/HTMLFormFu/MyValidator.pm t/lib/HTMLFormFu/RegressLocalization.pm t/lib/HTMLFormFu/RegressLocalization/en.pm t/lib/HTMLFormFu/TestLib.pm t/lib/MyApp/Schema.pm t/lib/MyApp/Schema/Dongle.pm t/lib/MyApp/Schema/Person.pm t/nested-elements-file_post.t t/templates/field_layout Makefile.PL100644001751001752 714312331714662 14471 0ustar00carlcarl000000000000HTML-FormFu-2.01 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.015. use strict; use warnings; use 5.008001; use ExtUtils::MakeMaker 6.30; use File::ShareDir::Install; install_share dist => "share"; my %WriteMakefileArgs = ( "ABSTRACT" => "HTML Form Creation, Rendering and Validation Framework", "AUTHOR" => "Carl Franks ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30", "File::ShareDir::Install" => "0.03" }, "DISTNAME" => "HTML-FormFu", "EXE_FILES" => [ "bin/html_formfu_deploy.pl", "bin/html_formfu_dumpconf.pl" ], "LICENSE" => "perl", "NAME" => "HTML::FormFu", "PREREQ_PM" => { "Carp" => 0, "Class::MOP::Method" => 0, "Clone" => "0.31", "Config::Any" => "0.18", "Cwd" => 0, "Data::Visitor" => "0.26", "Data::Visitor::Callback" => 0, "DateTime" => "0.54", "DateTime::Format::Builder" => "0.7901", "DateTime::Format::Natural" => 0, "DateTime::Format::Strptime" => "1.2000", "DateTime::Locale" => "0.45", "Email::Valid" => 0, "Encode" => 0, "Exporter" => "5.57", "Fatal" => 0, "File::Copy" => 0, "File::Find" => 0, "File::ShareDir" => 0, "File::Spec" => 0, "File::Temp" => 0, "HTML::Scrubber" => 0, "HTML::TokeParser::Simple" => "3.14", "HTTP::Headers" => "1.64", "Hash::Flatten" => 0, "IO::File" => 0, "List::MoreUtils" => 0, "List::Util" => 0, "Locale::Maketext" => 0, "Module::Pluggable" => 0, "Moose" => "1.00", "Moose::Role" => 0, "Moose::Util" => 0, "MooseX::Aliases" => 0, "Number::Format" => 0, "Path::Class::File" => 0, "Readonly" => 0, "Regexp::Common" => 0, "Scalar::Util" => 0, "Storable" => 0, "Task::Weaken" => 0, "YAML::XS" => "0.32" }, "TEST_REQUIRES" => { "CGI" => "3.37", "POSIX" => 0, "Test::Aggregate::Nested" => "0.371", "Test::Exception" => 0, "Test::More" => "0.92" }, "VERSION" => "2.01", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "CGI" => "3.37", "Carp" => 0, "Class::MOP::Method" => 0, "Clone" => "0.31", "Config::Any" => "0.18", "Cwd" => 0, "Data::Visitor" => "0.26", "Data::Visitor::Callback" => 0, "DateTime" => "0.54", "DateTime::Format::Builder" => "0.7901", "DateTime::Format::Natural" => 0, "DateTime::Format::Strptime" => "1.2000", "DateTime::Locale" => "0.45", "Email::Valid" => 0, "Encode" => 0, "Exporter" => "5.57", "Fatal" => 0, "File::Copy" => 0, "File::Find" => 0, "File::ShareDir" => 0, "File::Spec" => 0, "File::Temp" => 0, "HTML::Scrubber" => 0, "HTML::TokeParser::Simple" => "3.14", "HTTP::Headers" => "1.64", "Hash::Flatten" => 0, "IO::File" => 0, "List::MoreUtils" => 0, "List::Util" => 0, "Locale::Maketext" => 0, "Module::Pluggable" => 0, "Moose" => "1.00", "Moose::Role" => 0, "Moose::Util" => 0, "MooseX::Aliases" => 0, "Number::Format" => 0, "POSIX" => 0, "Path::Class::File" => 0, "Readonly" => 0, "Regexp::Common" => 0, "Scalar::Util" => 0, "Storable" => 0, "Task::Weaken" => 0, "Test::Aggregate::Nested" => "0.371", "Test::Exception" => 0, "Test::More" => "0.92", "YAML::XS" => "0.32" ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); { package MY; use File::ShareDir::Install qw(postamble); } MANIFEST.SKIP100644001751001752 31012331714662 14362 0ustar00carlcarl000000000000HTML-FormFu-2.01# Don't know if it's getting kept ^lib\/HTML\/FormFu\/Filter\/Default\.pm$ # not ready yet ^t-aggregate\/multiform-misc\/file ^benchmarks\b ^examples\/client-side-constraint\b ^xt\/ ^\.perltidyrc$ t000755001751001752 012331714662 12615 5ustar00carlcarl000000000000HTML-FormFu-2.01aggregate.t100644001751001752 25612331714662 15053 0ustar00carlcarl000000000000HTML-FormFu-2.01/tuse strict; use warnings; use Test::More; use Test::Aggregate::Nested; Test::Aggregate::Nested->new( { dirs => 't-aggregate', # verbose => 1, } )->run; HTML000755001751001752 012331714662 13664 5ustar00carlcarl000000000000HTML-FormFu-2.01/libFormFu.pm100644001751001752 24063212331714662 15627 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTMLpackage HTML::FormFu; $HTML::FormFu::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; with 'HTML::FormFu::Role::Render', 'HTML::FormFu::Role::CreateChildren', 'HTML::FormFu::Role::GetProcessors', 'HTML::FormFu::Role::ContainsElements', 'HTML::FormFu::Role::ContainsElementsSharedWithField', 'HTML::FormFu::Role::FormAndBlockMethods', 'HTML::FormFu::Role::FormAndElementMethods', 'HTML::FormFu::Role::FormBlockAndFieldMethods', 'HTML::FormFu::Role::NestedHashUtils', 'HTML::FormFu::Role::Populate', 'HTML::FormFu::Role::CustomRoles'; use HTML::FormFu::Attribute qw( mk_attrs mk_attr_accessors mk_output_accessors mk_inherited_accessors mk_inherited_merging_accessors ); use HTML::FormFu::Constants qw( $EMPTY_STR ); use HTML::FormFu::Constraint; use HTML::FormFu::Exception; use HTML::FormFu::FakeQuery; use HTML::FormFu::Filter; use HTML::FormFu::Inflator; use HTML::FormFu::Localize; use HTML::FormFu::ObjectUtil qw( form load_config_file load_config_filestem clone stash constraints_from_dbic parent _load_file ); use HTML::FormFu::Util qw( DEBUG DEBUG_PROCESS DEBUG_CONSTRAINTS debug require_class _get_elements xml_escape split_name _parse_args process_attrs _filter_components ); use Clone (); use List::Util qw( first ); use List::MoreUtils qw( any none uniq ); use Scalar::Util qw( blessed refaddr weaken reftype ); use Carp qw( croak ); use overload ( 'eq' => '_string_equals', '==' => '_object_equals', '""' => sub { return shift->render }, 'bool' => sub {1}, 'fallback' => 1, ); __PACKAGE__->mk_attr_accessors(qw( id action enctype method )); for my $name ( qw( _elements _output_processors _valid_names _plugins _models ) ) { has $name => ( is => 'rw', default => sub { [] }, lazy => 1, isa => 'ArrayRef', ); } has languages => ( is => 'rw', default => sub { ['en'] }, lazy => 1, isa => 'ArrayRef', traits => ['FormFuChained'], ); has input => ( is => 'rw', default => sub { {} }, lazy => 1, isa => 'HashRef', traits => ['FormFuChained'], ); has _processed_params => ( is => 'rw', default => sub { {} }, lazy => 1, isa => 'HashRef', ); has form_error_message_class => ( is => 'rw', default => 'form_error_message', lazy => 1, ); our @MULTIFORM_SHARED = (qw( javascript javascript_src indicator filename query_type force_error_message localize_class tt_module nested_name nested_subscript default_model tmp_upload_dir params_ignore_underscore )); for (@MULTIFORM_SHARED) { has $_ => ( is => 'rw', traits => ['FormFuChained'], ); } has submitted => ( is => 'rw', traits => ['FormFuChained'] ); has query => ( is => 'rw', traits => ['FormFuChained'] ); has _auto_fieldset => ( is => 'rw' ); __PACKAGE__->mk_output_accessors(qw( form_error_message )); *elements = \&element; *constraints = \&constraint; *filters = \&filter; *deflators = \&deflator; *inflators = \&inflator; *validators = \&validator; *transformers = \&transformer; *output_processors = \&output_processor; *loc = \&localize; *plugins = \&plugin; *add_plugins = \&add_plugin; our $build_defaults = { action => '', method => 'post', filename => 'form', render_method => 'string', tt_args => {}, tt_module => 'Template', query_type => 'CGI', default_model => 'DBIC', localize_class => 'HTML::FormFu::I18N', auto_error_message => 'form_%s_%t', error_tag => 'span', }; sub BUILD { my ( $self, $args ) = @_; $self->populate($build_defaults); return; } sub auto_fieldset { my ( $self, $element_ref ) = @_; # if there's no arg, just return whether there's an auto_fieldset already return $self->_auto_fieldset if !$element_ref; # if the argument isn't a reference, assume it's just a "1" meaning true, # and use an empty hashref if ( !ref $element_ref ) { $element_ref = {}; } $element_ref->{type} = 'Fieldset'; $self->element($element_ref); $self->_auto_fieldset(1); return $self; } sub default_values { my ( $self, $default_ref ) = @_; for my $field ( @{ $self->get_fields } ) { my $name = $field->nested_name; next if !defined $name; next if !exists $default_ref->{$name}; $field->default( $default_ref->{$name} ); } return $self; } sub model { my ( $self, $model_name ) = @_; $model_name ||= $self->default_model; # search models already loaded for my $model ( @{ $self->_models } ) { return $model if $model->type =~ /\Q$model_name\E$/; } # class not found, try require-ing it my $class = $model_name =~ s/^\+// ? $model_name : "HTML::FormFu::Model::$model_name"; require_class($class); my $model = $class->new( { type => $model_name, parent => $self, } ); push @{ $self->_models }, $model; return $model; } sub process { my ( $self, $query ) = @_; $self->input( {} ); $self->_processed_params( {} ); $self->_valid_names( [] ); $self->clear_errors; $query ||= $self->query; if ( defined $query && !blessed($query) ) { $query = HTML::FormFu::FakeQuery->new( $self, $query ); } # save it for further calls to process() if ($query) { DEBUG && debug( QUERY => $query ); $self->query($query); } # run all elements pre_process() methods for my $elem ( @{ $self->get_elements } ) { $elem->pre_process; } # run all plugins pre_process() methods for my $plugin ( @{ $self->get_plugins } ) { $plugin->pre_process; } # run all elements process() methods for my $elem ( @{ $self->get_elements } ) { $elem->process; } # run all plugins process() methods for my $plugin ( @{ $self->get_plugins } ) { $plugin->process; } my $submitted; if ( defined $query ) { eval { my @params = $query->param }; croak "Invalid query object: $@" if $@; $submitted = $self->_submitted($query); } DEBUG_PROCESS && debug( SUBMITTED => $submitted ); $self->submitted($submitted); if ($submitted) { my %input; my @params = $query->param; for my $field ( @{ $self->get_fields } ) { my $name = $field->nested_name; next if !defined $name; next if none { $name eq $_ } @params; if ( $field->nested ) { # call in list context so we know if there's more than 1 value my @values = $query->param($name); my $value = @values > 1 ? \@values : $values[0]; $self->set_nested_hash_value( \%input, $name, $value ); } else { my @values = $query->param($name); $input{$name} = @values > 1 ? \@values : $values[0]; } } DEBUG && debug( INPUT => \%input ); # run all field process_input methods for my $field ( @{ $self->get_fields } ) { $field->process_input( \%input ); } $self->input( \%input ); $self->_process_input; } # run all plugins post_process methods for my $elem ( @{ $self->get_elements } ) { $elem->post_process; } for my $plugin ( @{ $self->get_plugins } ) { $plugin->post_process; } return; } sub _submitted { my ( $self, $query ) = @_; my $indicator = $self->indicator; my $code; if ( defined($indicator) && ref $indicator ne 'CODE' ) { DEBUG_PROCESS && debug( INDICATOR => $indicator ); $code = sub { return defined $query->param($indicator) }; } elsif ( !defined $indicator ) { my @names = uniq grep {defined} map { $_->nested_name } @{ $self->get_fields }; DEBUG_PROCESS && debug( 'no indicator, checking fields...' => \@names ); $code = sub { grep { defined $query->param($_) } @names; }; } else { $code = $indicator; } return $code->( $self, $query ); } sub _process_input { my ($self) = @_; $self->_build_params; $self->_process_file_uploads; $self->_filter_input; $self->_constrain_input; $self->_inflate_input if !@{ $self->get_errors }; $self->_validate_input if !@{ $self->get_errors }; $self->_transform_input if !@{ $self->get_errors }; $self->_build_valid_names; return; } sub _build_params { my ($self) = @_; my $input = $self->input; my %params; for my $field ( @{ $self->get_fields } ) { my $name = $field->nested_name; next if !defined $name; next if exists $params{$name}; next if !$self->nested_hash_key_exists( $self->input, $name ) && !$field->default_empty_value; my $input = $self->get_nested_hash_value( $self->input, $name ); if ( ref $input eq 'ARRAY' ) { # can't clone upload filehandles # so create new arrayref of values $input = [@$input]; } elsif ( !defined $input && $field->default_empty_value ) { $input = ''; } $self->set_nested_hash_value( \%params, $name, $input, $name ); } $self->_processed_params( \%params ); DEBUG_PROCESS && debug( 'PROCESSED PARAMS' => \%params ); return; } sub _process_file_uploads { my ($self) = @_; my @names = uniq grep {defined} map { $_->nested_name } grep { $_->isa('HTML::FormFu::Element::File') } @{ $self->get_fields }; if (@names) { my $query_class = $self->query_type; if ( $query_class !~ /^\+/ ) { $query_class = "HTML::FormFu::QueryType::$query_class"; } require_class($query_class); my $params = $self->_processed_params; my $input = $self->input; for my $name (@names) { next if !$self->nested_hash_key_exists( $input, $name ); my $values = $query_class->parse_uploads( $self, $name ); $self->set_nested_hash_value( $params, $name, $values ); } } return; } sub _filter_input { my ($self) = @_; my $params = $self->_processed_params; for my $filter ( @{ $self->get_filters } ) { my $name = $filter->nested_name; next if !defined $name; next if !$self->nested_hash_key_exists( $params, $name ); $filter->process( $self, $params ); } return; } sub _constrain_input { my ($self) = @_; my $params = $self->_processed_params; for my $constraint ( @{ $self->get_constraints } ) { DEBUG_CONSTRAINTS && debug( 'FIELD NAME' => $constraint->field->nested_name, 'CONSTRAINT TYPE' => $constraint->type, ); $constraint->pre_process; my @errors = eval { $constraint->process($params) }; DEBUG_CONSTRAINTS && debug( ERRORS => \@errors ); DEBUG_CONSTRAINTS && debug( '$@' => $@ ); if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Constraint') ) { push @errors, $@; } elsif ($@) { push @errors, HTML::FormFu::Exception::Constraint->new; } for my $error (@errors) { if ( !$error->parent ) { $error->parent( $constraint->parent ); } if ( !$error->constraint ) { $error->constraint($constraint); } $error->parent->add_error($error); } } return; } sub _inflate_input { my ($self) = @_; my $params = $self->_processed_params; for my $inflator ( @{ $self->get_inflators } ) { my $name = $inflator->nested_name; next if !defined $name; next if !$self->nested_hash_key_exists( $params, $name ); next if any {defined} @{ $inflator->parent->get_errors }; my $value = $self->get_nested_hash_value( $params, $name ); my @errors; ( $value, @errors ) = eval { $inflator->process($value) }; if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Inflator') ) { push @errors, $@; } elsif ($@) { push @errors, HTML::FormFu::Exception::Inflator->new; } for my $error (@errors) { $error->parent( $inflator->parent ) if !$error->parent; $error->inflator($inflator) if !$error->inflator; $error->parent->add_error($error); } $self->set_nested_hash_value( $params, $name, $value ); } return; } sub _validate_input { my ($self) = @_; my $params = $self->_processed_params; for my $validator ( @{ $self->get_validators } ) { my $name = $validator->nested_name; next if !defined $name; next if !$self->nested_hash_key_exists( $params, $name ); next if any {defined} @{ $validator->parent->get_errors }; my @errors = eval { $validator->process($params) }; if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Validator') ) { push @errors, $@; } elsif ($@) { push @errors, HTML::FormFu::Exception::Validator->new; } for my $error (@errors) { $error->parent( $validator->parent ) if !$error->parent; $error->validator($validator) if !$error->validator; $error->parent->add_error($error); } } return; } sub _transform_input { my ($self) = @_; my $params = $self->_processed_params; for my $transformer ( @{ $self->get_transformers } ) { my $name = $transformer->nested_name; next if !defined $name; next if !$self->nested_hash_key_exists( $params, $name ); next if any {defined} @{ $transformer->parent->get_errors }; my $value = $self->get_nested_hash_value( $params, $name ); my (@errors) = eval { $transformer->process( $value, $params ) }; if ( blessed $@ && $@->isa('HTML::FormFu::Exception::Transformer') ) { push @errors, $@; } elsif ($@) { push @errors, HTML::FormFu::Exception::Transformer->new; } for my $error (@errors) { $error->parent( $transformer->parent ) if !$error->parent; $error->transformer($transformer) if !$error->transformer; $error->parent->add_error($error); } } return; } sub _build_valid_names { my ($self) = @_; my $params = $self->_processed_params; my $skip_private = $self->params_ignore_underscore; my @errors = $self->has_errors; my @names; my %non_param; for my $field ( @{ $self->get_fields } ) { my $name = $field->nested_name; next if !defined $name; next if $skip_private && $field->name =~ /^_/; if ( $field->non_param ) { $non_param{$name} = 1; } elsif ( $self->nested_hash_key_exists( $params, $name ) ) { push @names, $name; } } push @names, uniq grep { ref $params->{$_} ne 'HASH' } grep { !( $skip_private && /^_/ ) } grep { !exists $non_param{$_} } keys %$params; my %valid; CHECK: for my $name (@names) { for my $error (@errors) { next CHECK if $name eq $error; } $valid{$name}++; } my @valid = keys %valid; $self->_valid_names( \@valid ); return; } sub _hash_keys { my ( $hash, $subscript ) = @_; my @names; for my $key ( keys %$hash ) { if ( ref $hash->{$key} eq 'HASH' ) { push @names, map { $subscript ? "${key}[${_}]" : "$key.$_" } _hash_keys( $hash->{$key}, $subscript ); } elsif ( ref $hash->{$key} eq 'ARRAY' ) { push @names, map { $subscript ? "${key}[${_}]" : "$key.$_" } _array_indices( $hash->{$key}, $subscript ); } else { push @names, $key; } } return @names; } sub _array_indices { my ( $array, $subscript ) = @_; my @names; for my $i ( 0 .. $#{$array} ) { if ( ref $array->[$i] eq 'HASH' ) { push @names, map { $subscript ? "${i}[${_}]" : "$i.$_" } _hash_keys( $array->[$i], $subscript ); } elsif ( ref $array->[$i] eq 'ARRAY' ) { push @names, map { $subscript ? "${i}[${_}]" : "$i.$_" } _array_indices( $array->[$i], $subscript ); } else { push @names, $i; } } return @names; } sub submitted_and_valid { my ($self) = @_; return $self->submitted && !$self->has_errors; } sub params { my ($self) = @_; return {} if !$self->submitted; my @names = $self->valid; my %params; for my $name (@names) { my @values = $self->param($name); if ( @values > 1 ) { $self->set_nested_hash_value( \%params, $name, \@values ); } else { $self->set_nested_hash_value( \%params, $name, $values[0] ); } } return \%params; } sub param { my ( $self, $name ) = @_; croak 'param method is readonly' if @_ > 2; return if !$self->submitted; if ( @_ == 2 ) { return if !$self->valid($name); my $value = $self->get_nested_hash_value( $self->_processed_params, $name ); return if !defined $value; if ( ref $value eq 'ARRAY' ) { return wantarray ? @$value : $value->[0]; } else { return $value; } } # return a list of valid names, if no $name arg return $self->valid; } sub param_value { my ( $self, $name ) = @_; croak 'name parameter required' if @_ != 2; return undef if !$self->valid($name); # this is guaranteed to always return a single value my $value = $self->get_nested_hash_value( $self->_processed_params, $name ); return ref $value eq 'ARRAY' ? $value->[0] : $value; } sub param_array { my ( $self, $name ) = @_; croak 'name parameter required' if @_ != 2; # guaranteed to always return an arrayref return [] if !$self->valid($name); my $value = $self->get_nested_hash_value( $self->_processed_params, $name ); return [] if !defined $value; return ref $value eq 'ARRAY' ? $value : [$value]; } sub param_list { my ( $self, $name ) = @_; croak 'name parameter required' if @_ != 2; # guaranteed to always return an arrayref return if !$self->valid($name); my $value = $self->get_nested_hash_value( $self->_processed_params, $name ); return if !defined $value; return ref $value eq 'ARRAY' ? @$value : $value; } sub valid { my $self = shift; return if !$self->submitted; my @valid = @{ $self->_valid_names }; if (@_) { my $name = shift; return 1 if any { $name eq $_ } @valid; # not found - see if it's the name of a nested block my $parent; if ( defined $self->nested_name && $self->nested_name eq $name ) { $parent = $self; } else { ($parent) = first { $_->isa('HTML::FormFu::Element::Block') } @{ $self->get_all_elements( { nested_name => $name, } ) }; } if ( defined $parent ) { my $fail = any {defined} map { @{ $_->get_errors } } @{ $parent->get_fields }; return 1 if !$fail; } return; } # return a list of valid names, if no $name arg return @valid; } sub has_errors { my $self = shift; return if !$self->submitted; my @names = map { $_->nested_name } grep { @{ $_->get_errors } } grep { defined $_->nested_name } @{ $self->get_fields }; if (@_) { my $name = shift; return 1 if any {/\Q$name/} @names; return; } # return list of names with errors, if no $name arg return @names; } sub add_valid { my ( $self, $key, $value ) = @_; croak 'add_valid requires arguments ($key, $value)' if @_ != 3; $self->set_nested_hash_value( $self->input, $key, $value ); $self->set_nested_hash_value( $self->_processed_params, $key, $value ); if ( none { $_ eq $key } @{ $self->_valid_names } ) { push @{ $self->_valid_names }, $key; } return $value; } sub _single_plugin { my ( $self, $arg_ref ) = @_; if ( !ref $arg_ref ) { $arg_ref = { type => $arg_ref }; } elsif ( ref $arg_ref eq 'HASH' ) { # shallow clone $arg_ref = {%$arg_ref}; } else { croak 'invalid args'; } my $type = delete $arg_ref->{type}; my @return; my @names = map { ref $_ ? @$_ : $_ } grep {defined} ( delete $arg_ref->{name}, delete $arg_ref->{names} ); if (@names) { # add plugins to appropriate fields for my $x (@names) { for my $field ( @{ $self->get_fields( { nested_name => $x } ) } ) { my $new = $field->_require_plugin( $type, $arg_ref ); push @{ $field->_plugins }, $new; push @return, $new; } } } else { # add plugin directly to form my $new = $self->_require_plugin( $type, $arg_ref ); push @{ $self->_plugins }, $new; push @return, $new; } return @return; } around render => sub { my $orig = shift; my $self = shift; my $plugins = $self->get_plugins; for my $plugin (@$plugins) { $plugin->render; } my $output = $self->$orig; for my $plugin (@$plugins) { $plugin->post_render( \$output ); } return $output; }; sub render_data { my ( $self, $args ) = @_; my $render = $self->render_data_non_recursive( { elements => [ map { $_->render_data } @{ $self->_elements } ], $args ? %$args : (), } ); return $render; } sub render_data_non_recursive { my ( $self, $args ) = @_; my %render = ( filename => $self->filename, javascript => $self->javascript, javascript_src => $self->javascript_src, attributes => xml_escape( $self->attributes ), stash => $self->stash, $args ? %$args : (), ); $render{form} = \%render; weaken( $render{form} ); $render{object} = $self; if ($self->force_error_message || ( $self->has_errors && defined $self->form_error_message ) ) { $render{form_error_message} = xml_escape( $self->form_error_message ); $render{form_error_message_class} = $self->form_error_message_class; } return \%render; } sub string { my ( $self, $args_ref ) = @_; $args_ref ||= {}; my $html = $self->_string_form_start( $args_ref ); # form template $html .= "\n"; for my $element ( @{ $self->get_elements } ) { # call render, so that child elements can use a different renderer my $element_html = $element->render; # skip Blank fields if ( length $element_html ) { $html .= $element_html . "\n"; } } $html .= $self->_string_form_end( $args_ref ); $html .= "\n"; return $html; } sub _string_form_start { my ( $self, $args_ref ) = @_; # start_form template my $render_ref = exists $args_ref->{render_data} ? $args_ref->{render_data} : $self->render_data_non_recursive; my $html = sprintf "", process_attrs( $render_ref->{attributes} ); if ( defined $render_ref->{form_error_message} ) { $html .= sprintf qq{\n
%s
}, $render_ref->{form_error_message_class}, $render_ref->{form_error_message}, ; } if ( defined $render_ref->{javascript_src} ) { my $uri = $render_ref->{javascript_src}; my @uris = ref $uri eq 'ARRAY' ? @$uri : ($uri); for my $uri (@uris) { $html .= sprintf qq{\n}, $uri, ; } } if ( defined $render_ref->{javascript} ) { $html .= sprintf qq{\n}, $render_ref->{javascript}, ; } return $html; } sub _string_form_end { my ( $self ) = @_; # end_form template return ""; } sub start { my $self = shift; if ( 'tt' eq $self->render_method ) { return $self->tt( { filename => 'start_form', render_data => $self->render_data_non_recursive, } ); } else { return $self->_string_form_start( @_ ); } } sub end { my $self = shift; if ( 'tt' eq $self->render_method ) { return $self->tt( { filename => 'end_form', render_data => $self->render_data_non_recursive, } ); } else { return $self->_string_form_end( @_ ); } } sub hidden_fields { my ($self) = @_; return join $EMPTY_STR, map { $_->render } @{ $self->get_fields( { type => 'Hidden' } ) }; } sub output_processor { my ( $self, $arg ) = @_; my @return; if ( ref $arg eq 'ARRAY' ) { push @return, map { $self->_single_output_processor($_) } @$arg; } else { push @return, $self->_single_output_processor($arg); } return @return == 1 ? $return[0] : @return; } sub _single_output_processor { my ( $self, $arg ) = @_; if ( !ref $arg ) { $arg = { type => $arg }; } elsif ( ref $arg eq 'HASH' ) { $arg = Clone::clone($arg); } else { croak 'invalid args'; } my $type = delete $arg->{type}; my $new = $self->_require_output_processor( $type, $arg ); push @{ $self->_output_processors }, $new; return $new; } sub _require_output_processor { my ( $self, $type, $opt ) = @_; croak 'required arguments: $self, $type, \%options' if @_ != 3; croak "options argument must be hash-ref" if reftype($opt) ne 'HASH'; my $class = $type; if ( not $class =~ s/^\+// ) { $class = "HTML::FormFu::OutputProcessor::$class"; } $type =~ s/^\+//; require_class($class); my $object = $class->new( { type => $type, parent => $self, } ); # handle default_args my $parent = $self->parent; if ( $parent && exists $parent->default_args->{output_processor}{$type} ) { %$opt = ( %{ $parent->default_args->{output_processer}{$type} }, %$opt ); } $object->populate($opt); return $object; } sub get_output_processors { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_output_processors }; if ( exists $args{type} ) { @x = grep { $_->type eq $args{type} } @x; } return \@x; } sub get_output_processor { my $self = shift; my $x = $self->get_output_processors(@_); return @$x ? $x->[0] : (); } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu - HTML Form Creation, Rendering and Validation Framework =head1 SYNOPSIS Note: These examples make use of L. As of C v02.005, the L module is not bundled with C and is available in a stand-alone distribution. use HTML::FormFu; my $form = HTML::FormFu->new; $form->load_config_file('form.yml'); $form->process( $cgi_query ); if ( $form->submitted_and_valid ) { # do something with $form->params } else { # display the form $template->param( form => $form ); } If you're using L, a more suitable example might be: package MyApp::Controller::User; use Moose; extends 'Catalyst::Controller::HTML::FormFu'; sub user : FormFuChained CaptureArgs(1) { my ( $self, $c, $id ) = @_; my $rs = $c->model('Schema')->resultset('User'); $c->stash->{user} = $rs->find( $id ); return; } sub edit : FormFuChained('user') Args(0) FormConfig { my ( $self, $c ) = @_; my $form = $c->stash->{form}; my $user = $c->stash->{user}; if ( $form->submitted_and_valid ) { $form->model->update( $user ); $c->res->redirect( $c->uri_for( "/user/$id" ) ); return; } $form->model->default_values( $user ) if ! $form->submitted; } Note: Because L is automatically called for you by the Catalyst controller; if you make any modifications to the form within your action method, such as adding or changing elements, adding constraints, etc; you must call L again yourself before using L, any of the methods listed under L or L, or rendering the form. Here's an example of a config file to create a basic login form (all examples here are L, but you can use any format supported by L), you can also create forms directly in your perl code, rather than using an external config file. --- action: /login indicator: submit auto_fieldset: 1 elements: - type: Text name: user constraints: - Required - type: Password name: pass constraints: - Required - type: Submit name: submit constraints: - SingleValue =head1 DESCRIPTION L is a HTML form framework which aims to be as easy as possible to use for basic web forms, but with the power and flexibility to do anything else you might want to do (as long as it involves forms). You can configure almost any part of formfu's behaviour and output. By default formfu renders "XHTML 1.0 Strict" compliant markup, with as little extra markup as possible, but with sufficient CSS class names to allow for a wide-range of output styles to be generated by changing only the CSS. All methods listed below (except L) can either be called as a normal method on your C<$form> object, or as an option in your config file. Examples will mainly be shown in L config syntax. This documentation follows the convention that method arguments surrounded by square brackets C<[]> are I, and all other arguments are required. =head1 BUILDING A FORM =head2 new Arguments: [\%options] Return Value: $form Create a new L object. Any method which can be called on the L object may instead be passed as an argument to L. my $form = HTML::FormFu->new({ action => '/search', method => 'GET', auto_fieldset => 1, }); =head2 load_config_file Arguments: $filename Arguments: \@filenames Return Value: $form Accepts a filename or list of file names, whose filetypes should be of any format recognized by L. The content of each config file is passed to L, and so are added to the form. L may be called in a config file itself, so as to allow common settings to be kept in a single config file which may be loaded by any form. --- load_config_file: - file1 - file2 YAML multiple documents within a single file. The document start marker is a line containing 3 dashes. Multiple documents will be applied in order, just as if multiple filenames had been given. In the following example, multiple documents are taken advantage of to load another config file after the elements are added. (If this were a single document, the C would be called before C, regardless of its position in the file). --- elements: - name: one - name: two --- load_config_file: ext.yml Relative paths are resolved from the L directory if it is set, otherwise from the current working directory. See L for advice on organising config files. =head2 config_callback Arguments: \%options If defined, the arguments are used to create a L object during L which may be used to pre-process the config before it is sent to L. For example, the code below adds a callback to a form that will dynamically alter any config value ending in ".yml" to end in ".yaml" when you call L: $form->config_callback({ plain_value => sub { my( $visitor, $data ) = @_; s/\.yml/.yaml/; } }); Default Value: not defined This method is a special 'inherited accessor', which means it can be set on the form, a block element or a single element. When the value is read, if no value is defined it automatically traverses the element's hierarchy of parents, through any block elements and up to the form, searching for a defined value. =head2 populate Arguments: \%options Return Value: $form Each option key/value passed may be any L method-name and arguments. Provides a simple way to set multiple values, or add multiple elements to a form with a single method-call. Attempts to call the method-names in a semi-intelligent order (see the source of populate() in C for details). =head2 default_values Arguments: \%defaults Return Value: $form Set multiple field's default values from a single hash-ref. The hash-ref's keys correspond to a form field's name, and the value is passed to the field's L. This should be called after all fields have been added to the form, and before L is called (otherwise, call L again before rendering the form). =head2 config_file_path Arguments: $directory_name L defines where configuration files will be searched for, if an absolute path is not given to L. Default Value: not defined This method is a special 'inherited accessor', which means it can be set on the form, a block element or a single element. When the value is read, if no value is defined it automatically traverses the element's hierarchy of parents, through any block elements and up to the form, searching for a defined value. Is an L. =head2 indicator Arguments: $field_name Arguments: \&coderef If L is set to a fieldname, L will return true if a value for that fieldname was submitted. If L is set to a code-ref, it will be called as a subroutine with the two arguments C<$form> and C<$query>, and its return value will be used as the return value for L. If L is not set, L will return true if a value for any known fieldname was submitted. =head2 auto_fieldset Arguments: 1 Arguments: \%options Return Value: $fieldset This setting is suitable for most basic forms, and means you can generally ignore adding fieldsets yourself. Calling C<< $form->auto_fieldset(1) >> immediately adds a fieldset element to the form. Thereafter, C<< $form->elements() >> will add all elements (except fieldsets) to that fieldset, rather than directly to the form. To be specific, the elements are added to the I fieldset on the form, so if you add another fieldset, any further elements will be added to that fieldset. Also, you may pass a hashref to auto_fieldset(), and this will be used to set defaults for the first fieldset created. A few examples and their output, to demonstrate: 2 elements with no fieldset. --- elements: - type: Text name: foo - type: Text name: bar
2 elements with an L. --- auto_fieldset: 1 elements: - type: Text name: foo - type: Text name: bar
The 3rd element is within a new fieldset --- auto_fieldset: { id: fs } elements: - type: Text name: foo - type: Text name: bar - type: Fieldset - type: Text name: baz
Because of this behaviour, if you want nested fieldsets you will have to add each nested fieldset directly to its intended parent. my $parent = $form->get_element({ type => 'Fieldset' }); $parent->element('fieldset'); =head2 form_error_message Arguments: $string Normally, input errors cause an error message to be displayed alongside the appropriate form field. If you'd also like a general error message to be displayed at the top of the form, you can set the message with L. To set the CSS class for the message, see L. To change the markup used to display the message, edit the C template file. See L. Is an L. =head2 force_error_message If true, forces the L to be displayed even if there are no field errors. =head2 default_args Arguments: \%defaults Set defaults which will be added to every element, constraint, etc. of the given type which is subsequently added to the form. For example, to make every C element automatically have a size of C<10>, and make every C deflator automatically get its strftime set to C<%d/%m/%Y>: default_args: elements: Text: size: 10 deflators: Strftime: strftime: '%d/%m/%Y' An example to make all DateTime elements automatically get an appropriate Strftime deflator and a DateTime inflator: default_args: elements: DateTime: deflators: type: Strftime strftime: '%d-%m-%Y' inflators: type: DateTime parser: strptime: '%d-%m-%Y' =head3 Pseudo types As a special case, you can also use the C keys C, C and C to match any element which inherits from L or which C L or L. =head3 Alternatives Each C key can contain an C list using the C<|> divider: e.g. # apply the given class to any Element of type Password or Button default_args: elements: 'Password|Button': attrs: class: novalidate =head3 Match ancestor Each C key list can contain a type starting with C<+> to only match elements with an ancestor of the given type: e.g. # only apple the given class to an Input field within a Multi block default_args: elements: 'Input|+Multi': attrs: class: novalidate =head3 Don't match ancestor Each C key list can contain a type starting with C<-> to only match elements who do not have an ancestor of the given type: e.g. # apply the given class only to Input fields that are not in a Multi block default_args: elements: 'Input|-Multi': attrs: clasS: validate =head3 Order The arguments are applied in least- to most-specific order: C, C, C, C<$type>. Within each of these, arguments are applied in order of shortest-first to longest-last. The C key must match the value returned by C, e.g. L. If, for example, you have a custom element outside of the C namespace, which you load via C<< $form->element({ type => '+My::Custom::Element' }) >>, the key given to L should B include the leading C<+>, as that is stripped-out of the returned C value. Example: # don't include the leading '+' here default_args: elements: 'My::Custom::Element': attrs: class: whatever # do include the leading '+' here elements: - type: +My::Custom::Element =head3 Clashes L generates a single hashref to pass to L, merging arguments for each type in turn - meaning L is only called once in total - not once for each type. Because scalar values are B merged - this means later values will override earlier values: e.g. # Normally, calling $field->add_attrs({ class => 'input' }) # then calling $field->add_attrs({ class => 'not-in-multi' }) # would result in both values being retained: # class="input not-in-multi" # # However, default_args() creates a single data-structure to pass once # to populate(), so any scalar values will overwrite earlier ones # before they reach populate(). # # The below example would result in the longest-matching key # overwriting any others: # class="not-in-multi" # default_args: elements: Input: add_attrs: class: input 'Input:-Multi': add_attrs: class: not-in-multi =head3 Strictness Note: Unlike the proper methods which have aliases, for example L which is an alias for L - the keys given to C must be of the plural form, e.g.: default_args: elements: {} deflators: {} filters: {} constraints: {} inflators: {} validators: {} transformers: {} output_processors: {} =head2 javascript If set, the contents will be rendered within a C
EOF is( "$form", $xhtml ); auto_label.t100644001751001752 76412331714662 20127 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; use lib 't/lib'; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->localize_class('HTMLFormFu::I18N')->id('form')->auto_label('label_%n'); $form->element('Text')->name('foo'); $form->element('Text')->name('bar')->auto_label('label_%f_%n'); like( $form->get_field('foo'), qr!! ); like( $form->get_field('bar'), qr!! ); param_list.t100644001751001752 70212331714662 20143 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); $form->process( { foo => 'a', bar => [ 'b', 'c' ], } ); is_deeply( [ $form->param_list('foo') ], ['a'] ); is_deeply( [ $form->param_list('bar') ], [ 'b', 'c' ] ); is_deeply( [ $form->param_list('baz') ], [] ); has_errors.t100644001751001752 116312331714662 20201 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 6; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->element('Text')->name('string'); $form->constraint( 'Number', 'foo', 'bar', 'string' ); $form->process( { foo => 1, bar => [ 2, 3 ], string => 'yada', } ); ok( !grep { $_ eq 'foo' } $form->has_errors ); ok( !grep { $_ eq 'bar' } $form->has_errors ); ok( grep { $_ eq 'string' } $form->has_errors ); ok( !$form->has_errors('foo') ); ok( !$form->has_errors('bar') ); ok( $form->has_errors('string') ); get_filter.t100644001751001752 122612331714662 20156 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('name'); $form->element('Text')->name('age'); $form->filter( HTMLEscape => 'name', 'age' ); $form->filter( LowerCase => 'name' ); $form->filter('Whitespace'); { my @filters = $form->get_filter; is( @filters, 1, '1 filter' ); } { my @filters = $form->get_filter('name'); is( @filters, 1, '1 filter' ); } { my @filters = $form->get_filter( { name => 'age' } ); is( @filters, 1, '1 filter' ); } { my @filters = $form->get_filter( { type => 'LowerCase' } ); is( @filters, 1, '1 filter' ); } attributes.t100644001751001752 134212331714662 20217 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 6; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->id('foo')->action('/bar')->enctype('unknown')->method('get'); is( $form->id, 'foo', 'form id' ); is( $form->action, '/bar', 'form action' ); is( $form->enctype, 'unknown', 'form enctype' ); is( $form->method, 'get', 'form method' ); is_deeply( $form->attributes, { id => 'foo', action => '/bar', enctype => 'unknown', method => 'get', }, 'form attributes', ); my $form_xhtml = < EOF is( "$form", $form_xhtml ); get_errors.t100644001751001752 260612331714662 20210 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 14; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->element('Text')->name('string'); $form->constraint( 'Number', 'foo', 'bar', 'string' ); $form->process( { foo => 1, bar => [ 2, 'c' ], string => 'yada', } ); { my $errors = $form->get_errors; is( @$errors, 2 ); } { my $errors = $form->get_errors('bar'); is( @$errors, 1 ); is( $errors->[0]->name, 'bar' ); is( $errors->[0]->message, 'This field must be a number' ) } { my $errors = $form->get_errors( { name => 'string' } ); is( @$errors, 1 ); is( $errors->[0]->name, 'string' ); } { my $errors = $form->get_errors( { type => 'Number' } ); is( @$errors, 2 ); is( $errors->[0]->name, 'bar' ); is( $errors->[1]->name, 'string' ); } { my $errors = $form->get_errors( { name => 'bar', type => 'Number', } ); is( @$errors, 1 ); is( $errors->[0]->name, 'bar' ); is( $errors->[0]->type, 'Number' ); is( $errors->[0]->stage, 'constraint' ); my $xhtml = qq{
This field must be a number
}; is( $form->get_field('bar'), $xhtml ); } get_parent.t100644001751001752 277712331714662 20176 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 18; use HTML::FormFu; my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/form/get_parent.yml'); $form->get_all_element( { type => 'Repeatable' } )->repeat(2); $form->process; my $fieldset = $form->get_element; is( $fieldset->type, 'Fieldset' ); my $block_1 = $fieldset->get_element; is( $block_1->name, 'block_1' ); my $block_1_1 = $block_1->get_element; is( $block_1_1->name, 'block_1_1' ); my $text_1_1_1 = $block_1_1->get_element; is( $text_1_1_1->name, 'text_1_1_1' ); my $repeatable = $block_1->get_elements->[1]; is( $repeatable->name, 'repeatable_1_2' ); my $rep_1 = $repeatable->get_element; is( $rep_1->type, 'Block' ); my $rep_text_1 = $rep_1->get_element; is( $rep_text_1->name, 'rep_text_1' ); my $rep_2 = $repeatable->get_elements->[1]; is( $rep_2->type, 'Block' ); my $rep_text_2 = $rep_2->get_element; is( $rep_text_2->name, 'rep_text_2' ); my $submit_2 = $fieldset->get_elements->[1]; is( $submit_2->name, 'submit_2' ); ### ok( $text_1_1_1->get_parent() eq $block_1_1 ); ok( $text_1_1_1->get_parent( { tag => 'span' } ) eq $block_1_1 ); ok( $text_1_1_1->get_parent( { tag => 'div' } ) eq $block_1 ); ok( $text_1_1_1->get_parent( { type => 'Fieldset' } ) eq $fieldset ); ### ok( $rep_1->get_parent( { type => 'Repeatable' } ) eq $repeatable ); ok( $rep_2->get_parent( { type => 'Repeatable' } ) eq $repeatable ); ok( !defined $rep_2->get_parent( { type => 'Unknown' } ) ); ok( !defined $rep_2->get_parent( { foo => 'bar' } ) ); get_fields.t100644001751001752 232312331714662 20136 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 19; use HTML::FormFu; my $form = HTML::FormFu->new; my $fs = $form->element('Fieldset'); my $e1 = $fs->element('Text')->name('foo'); my $e2 = $fs->element('Hidden')->name('foo'); my $e3 = $fs->element('Hidden')->name('bar'); { my $fields = $form->get_fields; is( @$fields, 3 ); ok( $fields->[0] == $e1 ); ok( $fields->[1] == $e2 ); ok( $fields->[2] == $e3 ); ok( !@{ $e1->get_fields } ); ok( !@{ $e2->get_fields } ); ok( !@{ $e3->get_fields } ); } { my $fields = $form->get_fields( { type => 'Fieldset' } ); is( @$fields, 0 ); } { my $fields = $form->get_fields('foo'); is( @$fields, 2 ); ok( $fields->[0] == $e1 ); ok( $fields->[1] == $e2 ); } { my $fields = $form->get_fields( { name => 'foo' } ); is( @$fields, 2 ); ok( $fields->[0] == $e1 ); ok( $fields->[1] == $e2 ); } { my $fields = $form->get_fields( { type => 'Hidden' } ); is( @$fields, 2 ); ok( $fields->[0] == $e2 ); ok( $fields->[1] == $e3 ); } { my $fields = $form->get_fields( { name => 'foo', type => 'Hidden', } ); is( @$fields, 1 ); ok( $fields->[0] == $e2 ); } Constraint.pm100644001751001752 3645712331714662 17743 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFupackage HTML::FormFu::Constraint; $HTML::FormFu::Constraint::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Processor'; use HTML::FormFu::Exception::Constraint; use HTML::FormFu::Util qw( DEBUG_CONSTRAINTS DEBUG_CONSTRAINTS_WHEN debug ); use Clone (); use List::MoreUtils qw( any ); use Scalar::Util qw( blessed ); use Carp qw( croak ); use Clone (); use List::MoreUtils qw( any all ); use List::Util qw( first ); use Scalar::Util qw( reftype blessed ); has not => ( is => 'rw', traits => ['FormFuChained'] ); has force_errors => ( is => 'rw', traits => ['FormFuChained'] ); has when => ( is => 'rw', traits => ['FormFuChained'] ); has only_on_reps => ( is => 'rw', traits => ['FormFuChained'] ); sub repeatable_repeat { my ( $self, $repeatable, $new_block ) = @_; my $block_fields = $new_block->get_fields; # rename any 'when' fields { my $when = $self->when; if ( my $name = $when->{field} ) { my $field = $repeatable->get_field_with_original_name( $name, $block_fields ); if ( defined $field ) { DEBUG_CONSTRAINTS && debug( sprintf "Repeatable renaming constraint 'when{field}' '%s' to '%s'", $name, $field->nested_name, ); $when->{field} = $field->nested_name; } } elsif ( my $names = $when->{fields} ) { for my $name (@$names) { my $field = $repeatable->get_field_with_original_name( $name, $block_fields ); if ( defined $field ) { $when->{field} = $field->nested_name; } } } } } sub pre_process { } sub process { my ( $self, $params ) = @_; return unless $self->_run_this_rep; my $value = $self->_find_field_value($params); my @errors; # check when condition if ( !$self->_process_when($params) ) { DEBUG_CONSTRAINTS && debug('fail when() check - skipping constraint'); return; } if ( ref $value eq 'ARRAY' ) { push @errors, eval { $self->constrain_values( $value, $params ) }; if ($@) { push @errors, $self->mk_errors( { pass => 0, message => $@, } ); } } else { my $ok = eval { $self->constrain_value( $value, $params ) }; DEBUG_CONSTRAINTS && debug( 'CONSTRAINT RETURN VALUE' => $ok ); DEBUG_CONSTRAINTS && debug( '$@' => $@ ); push @errors, $self->mk_errors( { pass => ( $@ || !$ok ) ? 0 : 1, message => $@, } ); } return @errors; } sub _run_this_rep { my ($self) = @_; my $only_on_reps = $self->only_on_reps or return 1; my $current_rep = $self->field->repeatable_count or return 1; $only_on_reps = [$only_on_reps] if ( reftype($only_on_reps) || '' ) ne 'ARRAY'; return first { $current_rep == $_ } @$only_on_reps; } sub _find_field_value { my ( $self, $params ) = @_; my $value = $self->get_nested_hash_value( $params, $self->nested_name ); my @fields_with_this_name = @{ $self->form->get_fields( { nested_name => $self->nested_name } ) }; if ( @fields_with_this_name > 1 ) { my $field = $self->parent; my $index; for ( my $i = 0; $i <= $#fields_with_this_name; ++$i ) { if ( $fields_with_this_name[$i] eq $field ) { $index = $i; last; } } croak 'did not find ourself - how can this happen?' if !defined $index; if ( ( reftype($value) || '' ) eq 'ARRAY' ) { $value = $value->[$index]; } elsif ( $index == 0 ) { # keep $value } else { undef $value; } } return $value; } sub constrain_values { my ( $self, $values, $params ) = @_; my @errors; for my $value (@$values) { my $ok = eval { $self->constrain_value( $value, $params ) }; DEBUG_CONSTRAINTS && debug( 'CONSTRAINT RETURN VALUE' => $ok ); DEBUG_CONSTRAINTS && debug( '$@' => $@ ); push @errors, $self->mk_errors( { pass => ( $@ || !$ok ) ? 0 : 1, message => $@, } ); } return @errors; } sub constrain_value { croak "constrain_value() should be overridden"; } sub mk_errors { my ( $self, $args ) = @_; my $pass = $args->{pass}; my $message = $args->{message}; my @errors; my $force = $self->force_errors || $self->parent->force_errors; if ( !$pass || $force ) { my $error = $self->mk_error($message); $error->forced(1) if $pass; push @errors, $error; } return @errors; } sub mk_error { my ( $self, $err ) = @_; if ( !blessed $err || !$err->isa('HTML::FormFu::Exception::Constraint') ) { $err = HTML::FormFu::Exception::Constraint->new; } return $err; } sub _process_when { my ( $self, $params ) = @_; # returns 1 if when condition is fullfilled or not defined # returns 0 if when condition is defined and not fullfilled # If it's a callback, return callback's return value (so 'when' # condition is met if callback returns a true value) # get when condition my $when = $self->when; return 1 if !defined $when; # check type of 'when' croak "Parameter 'when' is not a hash ref" if ref $when ne 'HASH'; # field or callback must be defined my $when_field = $when->{field}; my $when_fields = $when->{fields}; my $when_any_field = $when->{any_field}; my $when_callback = $when->{callback}; croak "'field', 'fields', 'any_field' or 'callback' key must be defined in 'when'" if all { !defined } $when_field, $when_fields, $when_any_field, $when_callback; # Callback will be the preferred thing if ($when_callback) { no strict 'refs'; return $when_callback->( $params, $self ); } my $any; my @when_fields_value; if ($when_any_field) { croak "'any_field' is set to an empty list" if !@$when_any_field; $any = 1; @$when_fields = @$when_any_field; } if ($when_fields) { croak "'fields' is set to an empty list" if !@$when_fields; for my $name (@$when_fields) { my $value = $self->get_nested_hash_value( $params, $name ); push @when_fields_value, $value if defined $value; } } else { # nothing to constrain if field doesn't exist my $value = $self->get_nested_hash_value( $params, $when_field ); push @when_fields_value, $value if defined $value; } DEBUG_CONSTRAINTS_WHEN && debug( 'WHEN_FIELDS_VALUES' => \@when_fields_value ); if ( !@when_fields_value ) { DEBUG_CONSTRAINTS_WHEN && debug("No 'when' fields values exist - returning false"); return 0; } my @values; if ( defined( my $value = $when->{value} ) ) { push @values, $value; } elsif ( defined( my $values = $when->{values} ) ) { push @values, @$values; } # determine if condition is fulfilled my @ok; if (@values) { for my $value (@when_fields_value) { push @ok, any { $value eq $_ } @values; } } else { for my $value (@when_fields_value) { push @ok, $value ? 1 : 0; } } DEBUG_CONSTRAINTS_WHEN && debug( "'when' value matches" => \@ok ); my $return = $any ? any { $when->{not} ? !$_ : $_ } @ok : all { $when->{not} ? !$_ : $_ } @ok; DEBUG_CONSTRAINTS_WHEN && debug( "'when' return value" => $return ); return $return; } sub fetch_error_message { my ( $self ) = @_; my $error = HTML::FormFu::Exception::Constraint->new({ form => $self->form, parent => $self->parent, processor => $self, }); return $error->message; } sub clone { my $self = shift; my $clone = $self->SUPER::clone(@_); if ( defined( my $when = $self->when ) ) { $clone->when( Clone::clone $when ); } return $clone; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Constraint - Constrain User Input =head1 SYNOPSIS --- elements: - type: Text name: foo constraints: - type: Length min: 8 when: field: bar values: [ 1, 3, 5 ] - type: Text name: bar constraints: - Integer - Required constraints: - SingleValue =head1 DESCRIPTION User input is processed in the following order: =over =item L =item L =item L =item L =item L =back See L for further details. L can be called on any L, L (includes fieldsets) or L. If called on a field element, no C argument should be passed. If called on a L or L, if no C argument is provided, a new constraint is created for and added to every field on that form or block. See L for further details. =head1 METHODS =head2 type Returns the C argument originally used to create the constraint. =head2 not If true, inverts the results of the constraint - such that input that would otherwise fail will pass, and vise-versa. This value is ignored by some constraints - see the documentation for individual constraints for details. =head2 only_on_reps Argument: \@repeatable_count For constraints added to fields within a L element, if C is set, the constraint will only be run for fields whose L matches one of these set values. Not available for the constraints listed in L. =head2 message Arguments: $string Set the message which will be displayed if the constraint fails. =head2 message_xml Arguments: $string Variant of L which ensures the value won't be XML-escaped. =head2 message_loc Arguments: $string Variant of L which uses L to create the message. =head2 localize_args Provide arguments that should be passed to L to replace C<[_1]>, C<[_2]>, etc. in the localized string. =head2 force_errors See L for details. =head2 parent Returns the L object that the constraint is associated with. =head2 form Returns the L object that the constraint's field is attached to. =head2 name Shorthand for C<< $constraint->parent->name >> =head2 when Defines a condition for the constraint. Only when the condition is fullfilled the constraint will be applied. This method expects a hashref. The C or C must be supplied, all other fields are optional. If C or C is not supplied, the constraint will pass if the named field's value is true. The following keys are supported: =over =item field Nested-name of form field that shall be checked against - if C{value}> is set, the C condition passes if the named field's value matches that, otherwise the C condition passes if the named field's value is true. =item fields Array-ref of nested-names that shall be checked. The C condition passes if all named-fields' values pass, using the same rules as C above. =item any_field Array-ref of nested-names that shall be checked. The C condition passes if any named-fields' values pass, using the same rules as C above. =item value Expected value in the form field 'field' =item values Array of multiple values, one must match to fullfill the condition =item not Inverts the when condition - value(s) must not match =item callback A callback subroutine-reference or fully resolved subroutine name can be supplied to perform complex checks. An hashref of all parameters is passed to the callback sub. In this case all other keys are ignored, including not. You need to return a true value for the constraint to be applied or a false value to not apply it. The callback subroutine receives 2 arguments: =over 8 =item 1 C<$params> (hashref of all submitted parameters) =item 2 C<$constraint> (the Constraint object) =back =back =head1 EXPERIMENTAL METHODS =head2 fetch_error_message Return value: $string Attempt to return the error message that would be used if this constraint generated an error. This will generally be correct for simple constraints with a fixed message or which use a placeholder from a known value, such as L. This will generally C return the correct message for constraints which use L, where the field with an error is not known without actually fully processing a form submission. =head1 CORE CONSTRAINTS =over =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =item L =back =head1 NON-CORE CONSTRAINTS AVAILABLE ON CPAN =over =item L =back =head1 CAVEATS See L for a list of constraints that won't work within L. =head1 AUTHOR Carl Franks, C Based on the original source code of L, by Sebastian Riedel, C. =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut ObjectUtil.pm100644001751001752 1732012331714662 17647 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFupackage HTML::FormFu::ObjectUtil; $HTML::FormFu::ObjectUtil::VERSION = '2.01'; use strict; use warnings; use Exporter qw( import ); use HTML::FormFu::Util qw( _parse_args require_class _get_elements _filter_components _merge_hashes ); use Clone (); use Config::Any; use Clone (); use Data::Visitor::Callback; use File::Spec; use Scalar::Util qw( refaddr reftype weaken blessed ); use List::MoreUtils qw( none uniq ); use Carp qw( croak ); our @EXPORT_OK = ( qw( deflator load_config_file load_config_filestem form get_parent insert_before insert_after clone name stash constraints_from_dbic parent nested_name nested_names remove_element _string_equals _object_equals _load_file ), ); sub load_config_file { my ( $self, @files ) = @_; my $use_stems = 0; return _load_config( $self, $use_stems, @files ); } sub load_config_filestem { my ( $self, @files ) = @_; my $use_stems = 1; return _load_config( $self, $use_stems, @files ); } sub _load_config { my ( $self, $use_stems, @filenames ) = @_; if ( scalar @filenames == 1 && ref $filenames[0] eq 'ARRAY' ) { @filenames = @{ $filenames[0] }; } my $config_callback = $self->config_callback; my $data_visitor; if ( defined $config_callback ) { $data_visitor = Data::Visitor::Callback->new( %$config_callback, ignore_return_values => 1, ); } my $config_any_arg = $use_stems ? 'stems' : 'files'; my $config_any_method = $use_stems ? 'load_stems' : 'load_files'; my @config_file_path; if ( my $config_file_path = $self->config_file_path ) { if ( ref $config_file_path eq 'ARRAY' ) { push @config_file_path, @$config_file_path; } else { push @config_file_path, $config_file_path; } } else { push @config_file_path, File::Spec->curdir; } for my $file (@filenames) { my $loaded = 0; my $fullpath; foreach my $config_file_path (@config_file_path) { if ( defined $config_file_path && !File::Spec->file_name_is_absolute($file) ) { $fullpath = File::Spec->catfile( $config_file_path, $file ); } else { $fullpath = $file; } my $config = Config::Any->$config_any_method( { $config_any_arg => [$fullpath], use_ext => 1, driver_args => { General => { -UTF8 => 1 }, }, } ); next if !@$config; $loaded = 1; my ( $filename, $filedata ) = %{ $config->[0] }; _load_file( $self, $data_visitor, $filedata ); last; } croak "config file '$file' not found" if !$loaded; } return $self; } sub _load_file { my ( $self, $data_visitor, $data ) = @_; if ( defined $data_visitor ) { $data_visitor->visit($data); } for my $config ( ref $data eq 'ARRAY' ? @$data : $data ) { $self->populate( Clone::clone($config) ); } return; } sub form { my ($self) = @_; # micro optimization! this method's called a lot, so access # parent hashkey directly, instead of calling parent() while ( defined( my $parent = $self->{parent} ) ) { $self = $parent; } return $self; } sub clone { my ($self) = @_; my %new = %$self; $new{_elements} = [ map { $_->clone } @{ $self->_elements } ]; $new{attributes} = Clone::clone( $self->attributes ); $new{tt_args} = Clone::clone( $self->tt_args ); $new{model_config} = Clone::clone( $self->model_config ); if ( $self->can('_plugins') ) { $new{_plugins} = [ map { $_->clone } @{ $self->_plugins } ]; } $new{languages} = ref $self->languages ? Clone::clone( $self->languages ) : $self->languages; $new{default_args} = $self->default_args; my $obj = bless \%new, ref $self; map { $_->parent($obj) } @{ $new{_elements} }; return $obj; } sub name { my $self = shift; croak 'cannot use name() as a setter' if @_; return $self->parent->name; } sub nested_name { my $self = shift; croak 'cannot use nested_name() as a setter' if @_; return $self->parent->nested_name; } sub nested_names { my $self = shift; croak 'cannot use nested_names() as a setter' if @_; return $self->parent->nested_names; } sub stash { my $self = shift; $self->{stash} = {} if not exists $self->{stash}; return $self->{stash} if !@_; my %attrs = ( @_ == 1 ) ? %{ $_[0] } : @_; $self->{stash}->{$_} = $attrs{$_} for keys %attrs; return $self; } sub constraints_from_dbic { my ( $self, $source, $map ) = @_; $map ||= {}; $source = _result_source($source); for my $col ( $source->columns ) { _add_constraints( $self, $col, $source->column_info($col) ); } for my $col ( keys %$map ) { my $source = _result_source( $map->{$col} ); _add_constraints( $self, $col, $source->column_info($col) ); } return $self; } sub _result_source { my ($source) = @_; if ( blessed $source ) { $source = $source->result_source; } return $source; } sub _add_constraints { my ( $self, $col, $info ) = @_; return if !defined $self->get_field($col); return if !defined $info->{data_type}; my $type = lc $info->{data_type}; if ( $type =~ /(char|text|binary)\z/ && defined $info->{size} ) { # char, varchar, *text, binary, varbinary _add_constraint_max_length( $self, $col, $info ); } elsif ( $type =~ /int/ ) { _add_constraint_integer( $self, $col, $info ); if ( $info->{extra}{unsigned} ) { _add_constraint_unsigned( $self, $col, $info ); } } elsif ( $type =~ /enum|set/ && defined $info->{extra}{list} ) { _add_constraint_set( $self, $col, $info ); } } sub _add_constraint_max_length { my ( $self, $col, $info ) = @_; $self->constraint( { type => 'MaxLength', name => $col, max => $info->{size}, } ); } sub _add_constraint_integer { my ( $self, $col, $info ) = @_; $self->constraint( { type => 'Integer', name => $col, } ); } sub _add_constraint_unsigned { my ( $self, $col, $info ) = @_; $self->constraint( { type => 'Range', name => $col, min => 0, } ); } sub _add_constraint_set { my ( $self, $col, $info ) = @_; $self->constraint( { type => 'Set', name => $col, set => $info->{extra}{list}, } ); } sub parent { my $self = shift; if (@_) { $self->{parent} = shift; weaken( $self->{parent} ); return $self; } return $self->{parent}; } sub get_parent { my $self = shift; return $self->parent if !@_; my %args = _parse_args(@_); while ( defined( my $parent = $self->parent ) ) { for my $name ( keys %args ) { my $value; if ( $parent->can($name) && defined( $value = $parent->$name ) && $value eq $args{$name} ) { return $parent; } } $self = $parent; } return; } sub _string_equals { my ( $a, $b ) = @_; return blessed($b) ? ( refaddr($a) eq refaddr($b) ) : ( "$a" eq "$b" ); } sub _object_equals { my ( $a, $b ) = @_; return blessed($b) ? ( refaddr($a) eq refaddr($b) ) : undef; } 1; Element000755001751001752 012331714662 16453 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuHr.pm100644001751001752 135312331714662 17524 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Hr; $HTML::FormFu::Element::Hr::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::NonBlock'; after BUILD => sub { my $self = shift; $self->tag('hr'); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Hr - horizontal-rule element =head1 DESCRIPTION Horizontal-rule element. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut pt_br.pm100644001751001752 444112331714662 17350 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/I18Npackage HTML::FormFu::I18N::pt_br; $HTML::FormFu::I18N::pt_br::VERSION = '2.01'; use utf8; use Moose; extends 'HTML::FormFu::I18N'; our %Lexicon = ( form_error_message => 'Existem error no seu envio, veja os detalhes abaixo', form_constraint_allornone => 'Erro', form_constraint_ascii => 'Campo contém caracteres inválidos', form_constraint_autoset => 'Campo contém uma escolha inválida', form_constraint_bool => 'Campo deve ter um valor verdadeiro ou falso', form_constraint_callback => 'Entrada inválida', form_constraint_datetime => 'Data inválida', form_constraint_dependon => 'Erro', form_constraint_email => 'Este campo deve conter um endereço de email', form_constraint_equal => 'Erro', form_constraint_file => 'Não é um arquivo', form_constraint_file_mime => 'Tipo de arquivo inválido', form_constraint_file_size => 'Tamanho de arquivo inválido', form_constraint_integer => 'Este campo deverá ser um número inteiro', form_constraint_length => 'Entrada inválida', form_constraint_minlength => 'Deve ter pelo menos [_1] caracteres', form_constraint_minmaxfields => 'Entrada inválida', form_constraint_maxlength => 'Não pode ser maior que [_1] caracteres', form_constraint_number => 'Este campo tem que ser um número', form_constraint_printable => 'Este campo contém caracteres inválidos', form_constraint_range => 'Entrada inválida', form_constraint_regex => 'Entrada inválida', form_constraint_required => 'Este campo é obrigatório', form_constraint_set => 'Campo contém uma escolha inválida', form_constraint_singlevalue => 'Este campo só aceita um valor único', form_constraint_word => 'Campo contém caracteres inválidos', form_inflator_compounddatetime => 'Data inválida', form_inflator_datetime => 'Data inválida', form_validator_callback => 'Erro de validação', form_transformer_callback => 'Erro na transformação', form_inflator_imager => 'Erro ao abrir a imagem', form_validator_imager_size => 'Imagem muito grande', form_transformer_imager => 'Erro ao processar a imagem', ); __PACKAGE__->meta->make_immutable( inline_constructor => 0 ); 1; pt_pt.pm100644001751001752 342612331714662 17372 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/I18Npackage HTML::FormFu::I18N::pt_pt; $HTML::FormFu::I18N::pt_pt::VERSION = '2.01'; use utf8; use Moose; extends 'HTML::FormFu::I18N'; our %Lexicon = ( form_error_message => 'Existem erros na submição, veja os detalhes mais abaixo', form_constraint_allornone => 'Erro', form_constraint_ascii => 'Campo contém caracteres inválidos', form_constraint_autoset => 'Campo contém uma escolha inválida', form_constraint_bool => 'Campo tem de ser um valor booleano', form_constraint_dependon => 'Erro', form_constraint_email => 'Este campo tem de conter um endereço de email válido', form_constraint_equal => 'Erro', form_constraint_integer => 'Este campo tem de conter um número inteiro', form_constraint_length => 'Entrada inválida', form_constraint_minlength => 'Tem que conter pelo menos [_1] caracteres.', form_constraint_maxlength => 'Não pode conter mais de [_1] caracteres', form_constraint_number => 'Este campo deverá ser um número', form_constraint_printable => 'Este campo contém caracteres inválidos', form_constraint_range => 'Entrada inválida', form_constraint_regex => 'Entrada inválida', form_constraint_required => 'Este campo é obrigatório', form_constraint_set => 'Campo comtém uma escolha inválida', form_constraint_singlevalue => 'Este campo só aceita um valor único', form_constraint_word => 'Campo comtém caracteres inválidos', form_inflator_datetime => 'Data inválida', form_inflator_imager => 'Erro ao abrir a imagem', form_validator_imager_size => 'Imagem muito grande', form_transformer_imager => 'Erro ao processar a imagem', ); __PACKAGE__->meta->make_immutable( inline_constructor => 0 ); 1; zh_cn.pm100644001751001752 462412331714662 17346 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/I18Npackage HTML::FormFu::I18N::zh_cn; $HTML::FormFu::I18N::zh_cn::VERSION = '2.01'; use utf8; use Moose; extends 'HTML::FormFu::I18N'; our %Lexicon = ( form_error_message => '提交内容错误', form_constraint_allornone => '错误', form_constraint_ascii => '含有非ASCII字符', form_constraint_autoset => '无效选项', form_constraint_bool => '不是布尔值', form_constraint_callback => '无效输入', form_constraint_datetime => '无效日期', form_constraint_dependon => "如果'[_1]'不为空,此字段也不能为空", form_constraint_email => '不含邮件地址', form_constraint_equal => "与'[_1]'值不符", form_constraint_file => '不是文件', form_constraint_file_mime => '无效的文件类型', form_constraint_file_maxsize => '文件不能超过[_1]字节', form_constraint_file_minsize => '文件不能少于[_1]字节', form_constraint_file_size => '文件大小必须在[_1]和[_2]之间', form_constraint_integer => '不是数字', form_constraint_length => '长度必须在[_1]和[_2]之间', form_constraint_minlength => '至少[_1]个字符', form_constraint_minrange => '至少[_1]', form_constraint_minmaxfields => '无效输入', form_constraint_maxlength => '至多[_1]个字符', form_constraint_maxrange => '至多[_1]', form_constraint_number => '不是数字', form_constraint_printable => '含有不可打印字符', form_constraint_range => '必须在[_1]和[_2]之间', form_constraint_recaptcha => 'reCAPTCHA错误', form_constraint_regex => '无效输入', form_constraint_required => '不能为空', form_constraint_set => '无效选项', form_constraint_singlevalue => '不是单值', form_constraint_word => '不是单词', form_inflator_compounddatetime => '无效日期', form_inflator_datetime => '无效日期', form_validator_callback => 'Validator错误', form_transformer_callback => 'Transformer错误', form_inflator_imager => '打开图像文件错误', form_validator_imager_size => '图像文件太大', form_transformer_imager => '处理图像文件错误', ); __PACKAGE__->meta->make_immutable( inline_constructor => 0 ); 1; MyFormRole.pm100644001751001752 23312331714662 17755 0ustar00carlcarl000000000000HTML-FormFu-2.01/t/lib/HTMLFormFupackage HTMLFormFu::MyFormRole; use Moose::Role; sub custom_role_method { my ( $self ) = @_; return sprintf "form ID: %s", $self->id; } 1; MyDeflator.pm100644001751001752 32112331714662 17766 0ustar00carlcarl000000000000HTML-FormFu-2.01/t/lib/HTMLFormFupackage HTMLFormFu::MyDeflator; use strict; use warnings; use base 'HTML::FormFu::Deflator'; sub deflator { my ( $self, $value ) = @_; return if !defined $value; return $value->{value}; } 1; index.tt100644001751001752 23112331714662 20375 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/root [% form %] field100644001751001752 31212331714662 20357 0ustar00carlcarl000000000000HTML-FormFu-2.01/share/templates/tt/xhtml[% IF self.container_tag.defined %]<[% self.container_tag %][% process_attrs(self.container_attributes) %]> [% END %][% content %][% IF self.container_tag.defined %] [% END %]block100644001751001752 32112331714662 20366 0ustar00carlcarl000000000000HTML-FormFu-2.01/share/templates/tt/xhtml[% INCLUDE start_block %] [% IF self.content.defined %][% self.content %] [% ELSE %][% FOREACH element = self.elements %][% INCLUDE $element.filename self = element %] [% END %][% END %][% INCLUDE end_block %]repeatable000755001751001752 012331714662 16645 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregateclone.t100644001751001752 353112331714662 20274 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/repeatableuse strict; use warnings; use Scalar::Util qw/ refaddr /; use Test::More tests => 19; use HTML::FormFu; my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/repeatable/clone.yml'); $form->get_all_element( { type => 'Repeatable' } )->repeat(2); $form->process( { 'rep_1.foo' => 'a', 'rep_1.bar' => '', 'rep_2.foo' => '', 'rep_2.bar' => 'd', count => 2, } ); isa_ok( $form, 'HTML::FormFu' ); # fieldset my $fs = $form->get_element; isa_ok( $fs, 'HTML::FormFu::Element::Fieldset' ); is( refaddr( $fs->parent ), refaddr($form), ); # hidden field my $hidden = $form->get_field('count'); isa_ok( $hidden, 'HTML::FormFu::Element::Hidden' ); is( refaddr( $hidden->parent ), refaddr($fs), ); # repeatable my $rep = $fs->get_element( { type => 'Repeatable' } ); isa_ok( $rep, 'HTML::FormFu::Element::Repeatable' ); is( refaddr( $rep->parent ), refaddr($fs), ); # block 1 { my $block = $rep->get_elements->[0]; my $foo = $block->get_fields->[0]; is( refaddr( $foo->parent ), refaddr($block), ); is( refaddr( $foo->get_constraint->parent ), refaddr($foo), ); ok( !$foo->get_error ); my $bar = $block->get_fields->[1]; is( refaddr( $bar->parent ), refaddr($block), ); is( refaddr( $bar->get_constraint->parent ), refaddr($bar), ); is( refaddr( $bar->get_error->parent ), refaddr($bar), ); } # block 2 { my $block = $rep->get_elements->[1]; my $foo = $block->get_fields->[0]; is( refaddr( $foo->parent ), refaddr($block), ); is( refaddr( $foo->get_constraint->parent ), refaddr($foo), ); is( refaddr( $foo->get_error->parent ), refaddr($foo), ); my $bar = $block->get_fields->[1]; is( refaddr( $bar->parent ), refaddr($block), ); is( refaddr( $bar->get_constraint->parent ), refaddr($bar), ); ok( !$bar->get_error ); } word.t100644001751001752 252212331714662 20411 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 16; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('Word'); # Valid { $form->process( { foo => 'aaa', bar => 'bbbbbbb', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } # [space] - Invalid { $form->process( { foo => 'a', bar => 'b c', } ); ok( $form->valid('foo'), 'foo valid' ); ok( !$form->valid('bar'), 'foo valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( !grep { $_ eq 'bar' } $form->valid ); } # [newline] - Invalid { $form->process( { foo => 'a', bar => "b\nc", } ); ok( $form->valid('foo'), 'foo valid' ); ok( !$form->valid('bar'), 'foo valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( !grep { $_ eq 'bar' } $form->valid ); } # "0" is valid { $form->process( { foo => 0, bar => 2, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'foo valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } bool.t100644001751001752 111312331714662 20364 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('Bool'); # Valid { $form->process( { foo => 1, bar => 0, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => '01', bar => 'a', } ); ok( !$form->valid('foo'), 'foo not valid' ); ok( !$form->valid('bar'), 'bar not valid' ); } file.t100644001751001752 375412331714662 20365 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More; use HTML::FormFu; eval "use CGI"; if ($@) { plan skip_all => 'CGI required'; die $!; } plan tests => 10; # Copied from CGI.pm - http://search.cpan.org/perldoc?CGI %ENV = ( %ENV, 'SCRIPT_NAME' => '/test.cgi', 'SERVER_NAME' => 'perl.org', 'HTTP_CONNECTION' => 'TE, close', 'REQUEST_METHOD' => 'POST', 'SCRIPT_URI' => 'http://www.perl.org/test.cgi', 'SCRIPT_FILENAME' => '/home/usr/test.cgi', 'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ', 'HTTP_TE' => 'deflate,gzip;q=0.3', 'QUERY_STRING' => '', 'REMOTE_PORT' => '1855', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'PATH' => '/usr/local/bin:/usr/bin:/bin', 'REQUEST_URI' => '/test.cgi', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SCRIPT_URL' => '/test.cgi', 'SERVER_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/home/develop', 'HTTP_HOST' => 'www.perl.org' ); my $q; { my $file = 't-aggregate/elements/file_post.txt'; local *STDIN; open STDIN, "<", $file or die "missing test file $file"; binmode STDIN; $q = CGI->new; } my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/constraints/file.yml'); $form->process($q); { ok( $form->submitted ); ok( !$form->has_errors('hello_world') ); ok( !$form->has_errors('does_not_exist_gif') ); ok( $form->valid('hello_world') ); ok( $form->valid('does_not_exist_gif') ); } $form->process( { hello_world => 'not a file', } ); { ok( $form->submitted ); ok( $form->has_errors('hello_world') ); ok( !$form->has_errors('does_not_exist_gif') ); ok( !$form->valid('hello_world') ); ok( !$form->valid('does_not_exist_gif') ); } yaml_utf8.txt100644001751001752 312331714662 20223 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsfüyaml_utf8.yml100644001751001752 5312331714662 20232 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugs--- elements: - name: foo label: fü callback.t100644001751001752 240712331714662 20275 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 6; use HTML::FormFu; use lib 'lib'; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->filter('Callback') ->callback( sub { $_[0] =~ s/(\d)(\d)/$2$1/g; shift; } ); $form->element('Text')->name('bar')->filter('Callback'); $form->element('Text')->name('baz')->filter('Callback') ->callback('FilterCallback::my_filter'); my $original_foo = "ab123456"; my $filtered_foo = "ab214365"; my $original_bar = "ab123456"; my $filtered_bar = "ab123456"; my $original_baz = "abcdef"; my $filtered_baz = "ABCdef"; $form->process( { foo => $original_foo, bar => $original_bar, baz => $original_baz, } ); # foo is quoted is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); # bar is filtered is( $form->param('bar'), $filtered_bar, 'bar filtered' ); is( $form->params->{bar}, $filtered_bar, 'bar filtered' ); # baz is filtered is( $form->param('baz'), $filtered_baz, 'baz filtered' ); is( $form->params->{baz}, $filtered_baz, 'baz filtered' ); { package FilterCallback; use strict; use warnings; sub my_filter { my ($value) = @_; $value =~ tr/abc/ABC/; return $value; } } reverse.t100644001751001752 314112331714662 20354 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); # add element to test reverse_single reversing labels my $field1 = $form->element('Text')->name('foo1')->label('My Foo 1') ->reverse_single(1); # add element to test reverse_multi reversing labels in multi my $multi1 = $form->element('Multi')->label('My Multi 1'); $multi1->element('Text')->name('bar1')->label('My Bar 1')->reverse_multi(1); # add element to test reverse_multi not reversing labels outside multi my $field2 = $form->element('Text')->name('foo2')->label('My Foo 2')->reverse_multi(1); # add element to test reverse_single not reversing labels in multi my $multi2 = $form->element('Multi')->label('My Multi 2'); $multi2->element('Text')->name('bar2')->label('My Bar 2')->reverse_single(1); my $field1_xhtml = qq{
}; is( "$field1", $field1_xhtml, 'reverse_single normal' ); my $multi1_xhtml = qq{
}; is( "$multi1", $multi1_xhtml, 'reverse_multi normal' ); my $field2_xhtml = qq{
}; is( "$field2", $field2_xhtml, 'reverse_multi outside multi' ); my $multi2_xhtml = qq{
}; is( "$multi1", $multi1_xhtml, 'reverse_single inside multi' ); label.yml100644001751001752 27712331714662 20305 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elements--- elements: - type: Label name: foo - type: Label name: foo3 default: bar retain_default: 1 tag: div - type: Submit name: submit param_value.t100644001751001752 74412331714662 20312 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); $form->process( { foo => 'a', bar => [ 'b', 'c' ], } ); is( $form->param_value('foo'), 'a' ); is( $form->param_value('bar'), 'b' ); my @baz = $form->param_value('baz'); # we got 1 value ok( @baz == 1 ); # it was undef is( $baz[0], undef ); get_filters.t100644001751001752 247612331714662 20351 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 20; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('name')->filter('LowerCase'); $form->element('Text')->name('age'); $form->filter( HTMLEscape => 'name', 'age' ); $form->filter('Whitespace'); { my $filters = $form->get_filters; is( @$filters, 5, '5 filters' ); is( $filters->[0]->name, 'name' ); is( $filters->[1]->name, 'name' ); is( $filters->[2]->name, 'name' ); is( $filters->[3]->name, 'age' ); is( $filters->[4]->name, 'age' ); is( $filters->[0]->type, 'LowerCase' ); is( $filters->[1]->type, 'HTMLEscape' ); is( $filters->[2]->type, 'Whitespace' ); is( $filters->[3]->type, 'HTMLEscape' ); is( $filters->[4]->type, 'Whitespace' ); } { my $filters = $form->get_filters('name'); is( @$filters, 3, '3 filters' ); is( $filters->[0]->type, 'LowerCase' ); is( $filters->[1]->type, 'HTMLEscape' ); is( $filters->[2]->type, 'Whitespace' ); } { my $filters = $form->get_filters( { name => 'age' } ); is( @$filters, 2, '2 filters' ); is( $filters->[0]->type, 'HTMLEscape' ); is( $filters->[1]->type, 'Whitespace' ); } { my $filters = $form->get_filters( { type => 'LowerCase' } ); is( @$filters, 1, '1 filter' ); is( $filters->[0]->name, 'name' ); } get_element.t100644001751001752 171612331714662 20326 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 12; use HTML::FormFu; my $form = HTML::FormFu->new; my $fs = $form->element('Fieldset'); my $e1 = $fs->element('Text')->name('foo'); my $e2 = $fs->element('Hidden')->name('foo'); my $e3 = $fs->element('Hidden')->name('bar'); { my @elems = $form->get_element; is( @elems, 1 ); ok( $elems[0] == $fs ); } { my @elems = $form->get_element( { type => 'Fieldset' } ); is( @elems, 1 ); ok( $elems[0] == $fs ); } { my @elems = $fs->get_element('foo'); is( @elems, 1 ); ok( $elems[0] == $e1 ); } { my @elems = $fs->get_element( { name => 'foo' } ); is( @elems, 1 ); ok( $elems[0] == $e1 ); } { my @elems = $fs->get_element( { type => 'Hidden' } ); is( @elems, 1 ); ok( $elems[0] == $e2 ); } { my @elems = $fs->get_element( { name => 'foo', type => 'Hidden', } ); is( @elems, 1 ); ok( $elems[0] == $e2 ); } param_array.t100644001751001752 67112331714662 20313 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); $form->process( { foo => 'a', bar => [ 'b', 'c' ], } ); is_deeply( $form->param_array('foo'), ['a'] ); is_deeply( $form->param_array('bar'), [ 'b', 'c' ] ); is_deeply( $form->param_array('baz'), [] ); languages.yml100644001751001752 12512331714662 20313 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formlanguages: - de elements: - name: foo - name: bar constraints: - Required Transformer.pm100644001751001752 315012331714662 20061 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFupackage HTML::FormFu::Transformer; $HTML::FormFu::Transformer::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Processor'; use HTML::FormFu::Exception::Transformer; use Scalar::Util qw( blessed ); use Carp qw( croak ); sub process { my ( $self, $values, $params ) = @_; my $return; my @errors; if ( ref $values eq 'ARRAY' ) { my @return; for my $value (@$values) { my ($return) = eval { $self->transformer( $value, $params ) }; if ($@) { push @errors, $self->return_error($@); push @return, undef; } else { push @return, $return; } } $return = \@return; } else { ($return) = eval { $self->transformer( $values, $params ) }; if ($@) { push @errors, $self->return_error($@); } } $self->set_nested_hash_value( $params, $self->nested_name, $return ); return (@errors); } sub return_error { my ( $self, $err ) = @_; if ( !blessed $err || !$err->isa('HTML::FormFu::Exception::Transformer') ) { $err = HTML::FormFu::Exception::Transformer->new; } return $err; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Transformer - Transformer Base Class =head1 SYNOPSIS =head1 DESCRIPTION =head1 METHODS =head1 CORE TRANSFORMERS =over =item L =back =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut UploadParam.pm100644001751001752 371212331714662 17770 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFupackage HTML::FormFu::UploadParam; $HTML::FormFu::UploadParam::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; use Carp qw( croak ); use File::Temp qw( tempfile ); use Scalar::Util qw( reftype blessed weaken ); use Storable qw( nfreeze thaw ); has param => ( is => 'rw', traits => ['FormFuChained'], required => 1 ); has filename => ( is => 'rw', traits => ['FormFuChained'] ); sub form { my $self = shift; if (@_) { $self->{form} = shift; weaken( $self->{form} ); } return $self->{form}; } sub STORABLE_freeze { my ( $self, $cloning ) = @_; return if $cloning; my $fh = $self->{param}->can('fh') ? $self->{param}->fh : $self->{param}; seek $fh, 0, 0; local $/ = undef; my $data = <$fh>; if ( defined( my $dir = $self->form->tmp_upload_dir ) ) { my ( $fh, $filename ) = tempfile( DIR => $dir, UNLINK => 0 ); print $fh $data; close $fh; return nfreeze( { filename => $filename } ); } else { return nfreeze( { param => $data } ); } } sub STORABLE_thaw { my ( $self, $cloning, $serialized ) = @_; return if $cloning; my $data = thaw($serialized); my $filename = $data->{filename}; if ($filename) { open my $fh, '<', $filename or croak "could not open file in tmp dir: '$filename'"; $self->{param} = $fh; $self->{filename} = $filename; } else { my ($fh) = tempfile(); print $fh $data->{param}; seek $fh, 0, 0; $self->{param} = $fh; } return; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::UploadParam - accessor class =head1 DESCRIPTION =head1 SEE ALSO L, L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut URL.pm100644001751001752 615712331714662 17624 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::URL; $HTML::FormFu::Element::URL::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; use HTML::FormFu::Attribute qw( mk_output_accessors ); has http_only => ( is => 'rw', traits => ['FormFuChained'] ); has https_only => ( is => 'rw', traits => ['FormFuChained'] ); has error_message => ( is => 'rw', predicate => 'has_message', traits => ['FormFuChained'], ); has _has_auto_regex_constraint => ( is => 'rw', init_arg => undef, ); __PACKAGE__->mk_output_accessors(qw( message )); after BUILD => sub { my $self = shift; $self->field_type('url'); return; }; sub pre_process { my ( $self ) = @_; my $constraint; if ( $self->_has_auto_regex_constraint ) { $constraint = $self->_has_auto_regex_constraint; } else { my $scheme; if ( $self->http_only ) { $scheme = 'http'; } elsif ( $self->https_only ) { $scheme = 'https'; } else { $scheme = 'https?'; } $constraint = $self->constraint({ type => 'Regex', common => [ 'URI', 'HTTP', { -scheme => $scheme }, ], }); $self->_has_auto_regex_constraint( $constraint ); # 'pattern' attribute $self->pattern( "$scheme://.*" ); } my $message = $self->error_message; if ( defined $message && length $message ) { $constraint->message( $message ); } return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::URL - HTML5 URL form field =head1 SYNOPSIS my $element = $form->element( URL => 'foo' ); # no need to add a separate constraint =head1 DESCRIPTION HTML5 URL form field which provides native client-side validation in modern browsers. Creates an input field with C<>. Also sets the C attribute to restrict the client-side validation to only our desired schemes (http and/or https). This element automatically adds a L, so you don't have to. If neither L or L are set, the constraint allows any HTTP or HTTPS url. =head1 METHODS =head2 http_only =head2 https_only =head2 message Arguments: $string Set the error message on the L which is automatically added. =head2 message_xml Arguments: $string If you don't want your error message to be XML-escaped, use the L method instead of L. =head2 message_loc Arguments: $localization_key Set the error message using a L10N key. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L. L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Src.pm100644001751001752 140012331714662 17673 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Src; $HTML::FormFu::Element::Src::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element::Block'; after BUILD => sub { my $self = shift; $self->tag(undef); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Src - custom HTML element =head1 DESCRIPTION Allows you to add markup directly into the form, without surrounding C<<
>> tags. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Role000755001751001752 012331714662 15763 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuRender.pm100644001751001752 626112331714662 17705 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Rolepackage HTML::FormFu::Role::Render; $HTML::FormFu::Role::Render::VERSION = '2.01'; use HTML::FormFu::Util qw( process_attrs ); use Carp qw( croak ); use Scalar::Util qw( reftype ); use Moose::Role; our $SHARE_DIR; our $SHARE_ERROR; sub render { my $self = shift; my $render_method = $ENV{HTML_FORMFU_RENDER_METHOD} || $self->render_method; my $output = $self->$render_method(@_); for my $proc ( @{ $self->form->get_output_processors } ) { $output = $proc->process($output); } return $output; } sub tt { my ( $self, $args ) = @_; $args ||= {}; $args->{filename} = $self->filename if !exists $args->{filename}; $args->{render_data} = $self->render_data if !exists $args->{render_data}; my $form = $self->form; my $share_dir = _share_dir(); my %args = %{ $self->tt_args }; if ( defined $share_dir ) { # add $share_dir to the end of INCLUDE_PATH $args{INCLUDE_PATH} = exists $args{INCLUDE_PATH} ? ref $args{INCLUDE_PATH} eq 'ARRAY' ? [ @{ $args{INCLUDE_PATH} }, $share_dir ] : [ $args{INCLUDE_PATH}, $share_dir ] : [$share_dir]; } $args{ENCODING} = 'UTF-8' if !exists $args{ENCODING}; $args{RELATIVE} = 1; $args{RECURSION} = 1; my $tt_module = $form->tt_module; $tt_module = $ENV{HTML_FORMFU_TT_MODULE} if defined $ENV{HTML_FORMFU_TT_MODULE} && length $ENV{HTML_FORMFU_TT_MODULE}; my $class = $tt_module; $class =~ s|::|/|g; $class .= ".pm"; if ( !exists $::INC{$class} ) { eval { require $class }; croak $@ if $@; } my $template = $tt_module->new( \%args ); my $output; my %vars = ( self => $args->{render_data}, process_attrs => \&process_attrs, reftype => \&reftype, ); if ( !$template->process( $args->{filename}, \%vars, \$output ) ) { my $error = $template->error; if ( $error->type() eq 'file' && $error =~ /not found/i ) { croak <tt_args->{INCLUDE_PATH} to point to the template directory. ERROR_MESSAGE } else { croak $error; } } return $output; } sub _share_dir { return $SHARE_DIR if defined $SHARE_DIR; return if $SHARE_ERROR; eval { require 'File/ShareDir.pm'; require 'File/Spec.pm'; # dist_dir() doesn't reliably return the directory our files are in. # find the path of one of our files, then get the directory from that my $path = File::ShareDir::dist_file( 'HTML-FormFu', 'templates/tt/xhtml/form' ); my ( $volume, $dirs, $file ) = File::Spec->splitpath($path); $SHARE_DIR = File::Spec->catpath( $volume, $dirs, '' ); }; if ($@) { $SHARE_DIR = undef; $SHARE_ERROR = 1; return; } return $SHARE_DIR; } 1; MyBlockRole.pm100644001751001752 142612331714662 20131 0ustar00carlcarl000000000000HTML-FormFu-2.01/t/lib/HTMLFormFupackage HTMLFormFu::MyBlockRole; use Moose::Role; use List::Util qw( first ); around attributes => \&_myblockrole_attrs; around attrs => \&_myblockrole_attrs; around attributes_xml => \&_myblockrole_attrs; around attrs_xml => \&_myblockrole_attrs; my $key = 'class'; my $value = 'myblockrole'; sub _myblockrole_attrs { my $orig = shift; my $self = shift; if (@_) { return $self->$orig(@_); } my $attrs = $self->{attributes}; my $done; if ( exists $attrs->{$key} ) { my @vals = split /\s+/, $attrs->{$key}; if ( first { $_ eq $value } @vals ) { $done = 1; } } if ( !$done ) { $self->add_attrs({ $key => $value }); } return $attrs; }; 1; MyFieldRole.pm100644001751001752 146612331714662 20126 0ustar00carlcarl000000000000HTML-FormFu-2.01/t/lib/HTMLFormFupackage HTMLFormFu::MyFieldRole; use Moose::Role; around container_attributes => \&_myfieldrole_attrs; around container_attrs => \&_myfieldrole_attrs; around container_attributes_xml => \&_myfieldrole_attrs; around container_attrs_xml => \&_myfieldrole_attrs; my $key = 'class'; my $value = 'myfieldrole'; sub _myfieldrole_attrs { my $orig = shift; my $self = shift; if (@_) { return $self->$orig(@_); } my $attrs = $self->{container_attributes}; my $done; if ( exists $attrs->{$key} ) { my @vals = split /\s+/, $attrs->{$key}; if ( first { $_ eq $value } @vals ) { $done = 1; } } if ( !$done ) { $self->add_container_attrs({ $key => $value }); } return $attrs; }; 1; MyValidator.pm100644001751001752 40112331714662 20152 0ustar00carlcarl000000000000HTML-FormFu-2.01/t/lib/HTMLFormFupackage HTMLFormFu::MyValidator; use strict; use warnings; use base 'HTML::FormFu::Validator'; sub validate_value { my ( $self, $value, $params ) = @_; die HTML::FormFu::Exception::Validator->new if $value eq 'foo'; return 1; } 1; lib000755001751001752 012331714662 16364 5ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicodeunicode.pm100644001751001752 244312331714662 20513 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/libpackage unicode; use strict; use warnings; use Catalyst::Runtime '5.70'; # Set flags and add plugins for the application # # -Debug: activates the debug mode for very useful log messages # ConfigLoader: will load the configuration from a YAML file in the # application's home directory # Static::Simple: will serve static files from the application's root # directory use Catalyst qw/-Debug ConfigLoader Static::Simple Unicode /; our $VERSION = '0.01'; # Configure the application. # # Note that settings in unicode.yml (or other external # configuration file that you set up manually) take precedence # over this when using ConfigLoader. Thus configuration # details given here can function as a default configuration, # with a external configuration file acting as an override for # local deployment. __PACKAGE__->config( name => 'unicode' ); # Start the application __PACKAGE__->setup; =head1 NAME unicode - Catalyst based application =head1 SYNOPSIS script/unicode_server.pl =head1 DESCRIPTION [enter your description here] =head1 SEE ALSO L, L =head1 AUTHOR Carl Franks =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; field_change_name.t100644001751001752 42712331714662 20441 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregateuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Required'); ok( $form->get_constraint('foo') ); $form->get_field('foo')->name('bar'); ok( $form->get_constraint('bar') ); regex.t100644001751001752 140312331714662 20545 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 8; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('Regex'); # Valid { $form->process( { foo => 'aaa', bar => 'bbbbbbb', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } # "0" is valid { $form->process( { foo => 0, bar => 2, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'foo valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } equal.t100644001751001752 414712331714662 20552 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 21; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Equal') ->others( [ 'bar', 'baz' ] ); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); # Valid { $form->process( { foo => 'yada', bar => 'yada', baz => 'yada', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( $form->valid('baz'), 'baz valid' ); } # Valid { $form->process( { foo => '', bar => '', baz => '', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( $form->valid('baz'), 'baz valid' ); } # Valid { $form->process( { foo => [ 'a', 'b' ], bar => [ 'a', 'b' ], baz => [ 'b', 'a' ], } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( $form->valid('baz'), 'baz valid' ); } # Invalid { $form->process( { foo => 'yada', bar => 'yada', baz => 'x', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( !$form->valid('baz'), 'baz not valid' ); } # Invalid { $form->process( { foo => 'yada', bar => 'yada', baz => '', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( !$form->valid('baz'), 'baz not valid' ); } # Invalid { $form->process( { foo => '', bar => 'yada', baz => 'yada', } ); ok( $form->valid('foo'), 'foo valid' ); ok( !$form->valid('bar'), 'bar not valid' ); ok( !$form->valid('baz'), 'baz not valid' ); } # Invalid { $form->process( { foo => [ 'a', 'b' ], bar => [ 'a', 'b' ], baz => ['a'], } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( !$form->valid('baz'), 'baz not valid' ); } email.t100644001751001752 61312331714662 20504 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Email'); # Valid { $form->process( { foo => 'cfranks@cpan.org', } ); ok( $form->valid('foo'), 'foo valid' ); } # Invalid { $form->process( { foo => 'cfranks@cpan', } ); ok( $form->has_errors('foo'), 'foo has errors' ); } ascii.t100644001751001752 113512331714662 20525 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('ASCII'); # Valid { $form->process( { foo => 'aaa', bar => 'bbbbbbb', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'aaa', bar => '日本語', } ); ok( $form->valid('foo'), 'foo valid' ); ok( !$form->valid('bar'), 'bar not valid' ); } range.t100644001751001752 116312331714662 20532 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Range')->min(3)->max(5); $form->element('Text')->name('bar')->constraint('Range')->min(3)->max(5); # Valid { $form->process( { foo => 3, bar => 4, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 1, bar => 6, } ); ok( !$form->valid('foo'), 'foo not valid' ); ok( !$form->valid('bar'), 'bar not valid' ); } examples000755001751001752 012331714662 16357 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregatefield_as.t100644001751001752 374612331714662 20464 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/examplesuse strict; use warnings; use Test::More; eval { require Template; }; if ($@) { plan skip_all => 'Template.pm required'; die $@; } else { plan tests => 2; } use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Password')->name('foo')->label('Foo') ->label_attributes( { class => 'my_label' } )->comment('Comment') ->render_value(1); $form->element('Submit')->name('submit'); $form->constraint( Required => 'foo' ); my $template = Template->new; my $data = do { local $/; }; my $output; $template->process( \$data, { form => $form }, \$output ) or die $template->error; my $xhtml = <
Comment
Comment
EOF is( $output, $xhtml ); # check that errors are carried to the new field { my $xhtml = <
This field is required Comment
This field is required Comment
EOF $form->process( { submit => 'Submit', } ); my $output = undef; $template->process( \$data, { form => $form }, \$output ) or die $template->error; is( $output, $xhtml ); } __DATA__ [% form.start %] [% form.get_field('foo') %] [% form.get_field('foo').as('Text', 'disabled', 'disabled') %] [% form.get_field('submit') %] [% form.end %] form_input.t100644001751001752 54112331714662 20512 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nesteduse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new; $form->auto_fieldset( { nested_name => 'foo' } ); my $bar = $form->element('Text')->name('bar'); $form->process( { 'foo.bar' => 'x', foo => { bar => 'x', }, } ); is_deeply( $form->input, { foo => { bar => 'x', }, }, ); uppercase.t100644001751001752 63012331714662 20504 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->filter('UpperCase'); my $original_foo = "Foo Bar"; my $filtered_foo = "FOO BAR"; $form->process( { foo => $original_foo, } ); # foo is filtered is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); lowercase.t100644001751001752 63012331714662 20501 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->filter('LowerCase'); my $original_foo = "Foo Bar"; my $filtered_foo = "foo bar"; $form->process( { foo => $original_foo, } ); # foo is filtered is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); copyvalue.t100644001751001752 123112331714662 20542 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar')->filter('CopyValue')->field('foo'); my $original_foo = "ab123456"; my $filtered_foo = "ab123456"; my $filtered_bar = $filtered_foo; $form->process( { foo => $original_foo, bar => undef, } ); # foo is quoted is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); # bar is filtered is( $form->param('bar'), $filtered_bar, 'bar filtered' ); is( $form->params->{bar}, $filtered_bar, 'bar filtered' ); trimedges.t100644001751001752 71012331714662 20477 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo')->filter('TrimEdges'); my $original_foo = " Foo Bar "; my $filtered_foo = "Foo Bar"; $form->process( { foo => $original_foo } ); # foo is filtered is( $form->params->{foo}, $filtered_foo ); like( $form->get_field('foo'), qr/$original_foo/ ); escaping.t100644001751001752 177012331714662 20500 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo&')->label('comment('foo>') ->default("'foo")->attrs( { class => "foo'" } ) ->add_attrs( { class => 'bar"' } )->container_attrs( { class => 'foo"' } ); $form->element('Text')->name('foo&')->label_xml('comment_xml('foo>') ->default_xml("'foo")->attrs_xml( { class => "foo'" } ) ->add_attrs_xml( { class => 'bar"' } ) ->container_attrs_xml( { class => 'foo"' } ); my $form_xhtml = <
foo>
EOF is( "$form", $form_xhtml, 'stringified form' ); datetime.t100644001751001752 4643412331714662 20531 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 16; use HTML::FormFu; use DateTime; my $dt = DateTime->new( day => 6, month => 8, year => 2007, hour => 1, minute => 0, ); my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/elements/datetime.yml'); $form->get_field('foo')->default($dt); $form->process; is( "$form", <
HTML $form->process( { foo_hour => '00', foo_minute => '00', foo_day => 30, foo_month => 6, foo_year => 2007, bar_hour => '01', bar_minute => '30', bar_day => 1, bar_month => 7, bar_year => 2007, } ); ok( $form->submitted_and_valid ); my $foo = $form->param('foo'); my $bar = $form->param('bar'); isa_ok( $foo, 'DateTime' ); ok( !ref $bar ); is( $foo, "06/30/2007 00:00" ); is( $bar, "01-07-2007 01:30" ); like( $form->get_field('foo'), qr/\Q
format. Overwrites any default value set in L, L or L. =head2 default_natural Arguments: $date_string - type: Date default_natural: 'today' Accepts a date/time string suitable for passing to L. =head2 default_datetime_args - type: Date default_natural: 'today' default_datetime_args: set_time_zone: 'Europe/London' Accepts a hashref of method-names / values that will be called on the L
L object, before the select fields' values are set from it. =head2 strftime Default Value: "%d-%m-%Y" The format of the date as returned by L, if L is not set. If L is used, this is still the format that the parameter will be in prior to the DateTime inflator being run; which is what any L and L will receive. =head2 day Arguments: \%setting Set values effecting the C select menu. Known keys are: =head3 name Override the auto-generated name of the select menu. =head3 default Set the default value of the select menu =head3 prefix Arguments: $value Arguments: \@values A string or arrayref of strings to be inserted into the start of the select menu. Each value is only used as the label for a select item - the value for each of these items is always the empty string C<''>. =head3 prefix_loc Arguments: $localization_key Arguments: \@localization_keys A localized string or arrayref of localized strings to be inserted into the start of the select menu. Each value is localized and then only used as the label for a select item - the value for each of these items is always the empty string C<''>. Use C insted of C. =head2 month Arguments: \%setting Set values effecting the C select menu. Known keys are: =head3 name Override the auto-generated name of the select menu. =head3 default Set the default value of the select menu =head3 prefix Arguments: $value Arguments: \@values A string or arrayref of strings to be inserted into the start of the select menu. Each value is only used as the label for a select item - the value for each of these items is always the empty string C<''>. =head3 prefix_loc Arguments: $localization_key Arguments: \@localization_keys A localized string or arrayref of localized strings to be inserted into the start of the select menu. Each value is localized and then only used as the label for a select item - the value for each of these items is always the empty string C<''>. Use C insted of C. =head3 names Arguments: \@months A list of month names used for the month menu. If not set, the list of month names is obtained from L using the locale set in L. =head3 short_names Argument: bool If true (and C is not set) the list of abbreviated month names is obtained from L using the locale set in L. =head2 year Arguments: \%setting Set values effecting the C select menu. Known keys are: =head3 name Override the auto-generated name of the select menu. =head3 default Set the default value of the select menu =head3 prefix Arguments: $value Arguments: \@values A string or arrayref of strings to be inserted into the start of the select menu. Each value is only used as the label for a select item - the value for each of these items is always the empty string C<''>. =head3 prefix_loc Arguments: $localization_key Arguments: \@localization_keys A localized string or arrayref of localized strings to be inserted into the start of the select menu. Each value is localized and then only used as the label for a select item - the value for each of these items is always the empty string C<''>. Use C insted of C. =head3 list Arguments: \@years A list of years used for the year menu. If this is set, C, C and C are ignored. =head3 reference Arguments: $year Default Value: the current year, calculated from L If C is not set, the list is created from the range of C to C. =head3 less Arguments: $count Default Value: 0 =head3 plus Arguments: $count Default Value: 10 =head3 reverse Arguments: bool Default Value: 0 If true, the list of years is listed in reverse (decreasing) order. =head2 field_order Arguments: \@fields Default Value: ['day', 'month', 'year'] Specify the order of the date fields in the rendered HTML. Not all 3 fields are required. No single field can be used more than once. =head2 auto_inflate If true, a L will automatically be added to the element, and it will be given a formatter so that stringification will result in the format specified in L. If you require the DateTime Inflator to have a different stringification format to the format used internally by your Filters and Constraints, then you must explicitly add your own DateTime Inflator, rather than using L. =head1 CAVEATS Although this element inherits from L, its behaviour for the methods Lfilters|HTML::FormFu/filters>, Lconstraints|HTML::FormFu/constraints>, Linflators|HTML::FormFu/inflators>, Lvalidators|HTML::FormFu/validators> and Ltransformers|HTML::FormFu/transformers> is more like that of a L, meaning all processors are added directly to the date element, not to its select-menu child elements. This element's L and L are inherited from L, and so have the same behaviour. However, it overrides the C method, such that it returns both itself and its child elements. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut File.pm100644001751001752 233612331714662 20034 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::File; $HTML::FormFu::Element::File::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; after BUILD => sub { my $self = shift; $self->field_type('file'); $self->form->enctype('multipart/form-data'); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::File - File upload form field =head1 SYNOPSIS --- elements: type: File name: photo my $photo = $form->param('photo'); my $blob = $photo->slurp; =head1 DESCRIPTION File upload form field. See the documentation relevant to the L you're using: =over =item L =item L =item L =back =head1 METHODS =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Text.pm100644001751001752 152212331714662 20075 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Text; $HTML::FormFu::Element::Text::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; after BUILD => sub { my $self = shift; $self->field_type('text'); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Text - Text form field =head1 SYNOPSIS my $element = $form->element( Text => 'foo' ); =head1 DESCRIPTION Text form field. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L. L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Filter000755001751001752 012331714662 16307 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuSplit.pm100644001751001752 232712331714662 20104 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Filterpackage HTML::FormFu::Filter::Split; $HTML::FormFu::Filter::Split::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Filter'; has regex => ( is => 'rw', traits => ['FormFuChained'] ); has limit => ( is => 'rw', traits => ['FormFuChained'] ); sub filter { my ( $self, $value ) = @_; return if !defined $value; my $regex = $self->regex; my $limit = $self->limit || 0; $regex = '' if !defined $regex; my @values = split /$regex/, $value, $limit; return if !@values; return \@values; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Filter::Split - filter splitting a singe value into an arrayref =head1 SYNOPSIS type: Split regex: '-' =head1 DESCRIPTION Split a single input value into an arrayref of values. =head1 METHODS =head2 regex A regex object or string to be passed as the C argument to C. Default Value: '' (emtpy string) =head2 limit A number passed as the C argument to C. Default Value: 0 =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Regex.pm100644001751001752 341212331714662 20057 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Filterpackage HTML::FormFu::Filter::Regex; $HTML::FormFu::Filter::Regex::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Filter'; use HTML::FormFu::Constants qw( $EMPTY_STR ); has match => ( is => 'rw', traits => ['FormFuChained'] ); has replace => ( is => 'rw', traits => ['FormFuChained'] ); has eval => ( is => 'rw', traits => ['FormFuChained'] ); sub filter { my ( $self, $value ) = @_; return if !defined $value; my $match = defined $self->match ? $self->match : qr/./; my $replace = defined $self->replace ? $self->replace : $EMPTY_STR; if ( $self->eval ) { $value =~ s/$match/$replace/gee; } else { $value =~ s/$match/$replace/g; } return $value; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Filter::Regex - regexp-based match/replace filter =head1 SYNOPSIS The following filter would turn C<1234-5678> into C<****-****>. type: Regex match: \d replace: * =head1 DESCRIPTION Regular expression-based match / replace filter. =head1 METHODS =head2 match A regex object or string to be used in the "left-hand side" of a C regular expression. Default Value: qr/./ =head2 replace A string to be used in the "right-hand side" of a C regular expression. The string will replace every occurrence of L. Default Value: '' =head2 eval Arguments: $bool If true, the regex modifier C is used, so that the contents of the L string are C'd. This allows the use of variables such as C<$1> or any other perl expression. =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut ElementSetup.pm100644001751001752 25212331714662 20335 0ustar00carlcarl000000000000HTML-FormFu-2.01/t/lib/HTMLFormFupackage HTMLFormFu::ElementSetup; use strict; use warnings; use base 'HTML::FormFu::Element::Text'; sub setup { my ($self) = @_; $::name = $self->name; } 1; 05_repeated_render.t100644001751001752 72712331714662 20510 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregateuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/04basic.yml'); # check output is still exactly the same after rendering again { my $html = "$form"; is( $html, "$form" ); } # and after submitted form { $form->process( { age => 'abc', } ); my $html = "$form"; is( $html, "$form" ); } block_insert_after.t100644001751001752 152012331714662 20723 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregateuse strict; use warnings; use Test::More tests => 7; use HTML::FormFu; { my $form = HTML::FormFu->new; my $fs = $form->element('Fieldset'); my $e1 = $fs->element('Text')->name('foo'); my $e2 = $fs->element('Hidden')->name('foo'); my $e3 = $e1->clone; $fs->insert_after( $e3, $e1 ); my $elems = $fs->get_elements; is( scalar(@$elems), 3 ); ok( $elems->[0] == $e1 ); ok( $elems->[1] == $e3 ); ok( $elems->[2] == $e2 ); } # ensure elements only occur once { my $form = HTML::FormFu->new; my $fs = $form->element('Fieldset'); my $e1 = $fs->element( { name => 'foo' } ); my $e2 = $fs->element( { name => 'bar' } ); $fs->insert_after( $e1, $e2 ); my $elems = $fs->get_elements; is( scalar(@$elems), 2 ); ok( $elems->[0] == $e2 ); ok( $elems->[1] == $e1 ); } field_accessor_loc.t100644001751001752 105512331714662 20671 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregateuse strict; use warnings; use Test::More tests => 1; use lib 't/lib'; use HTML::FormFu; my $form = HTML::FormFu->new( { localize_class => 'HTMLFormFu::I18N', tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' }, } ); $form->element('Text')->name('foo')->label_loc('test_label') ->comment_loc('test_comment')->default_loc('test_default_value'); my $xhtml = qq{
My Comment
}; is( $form->get_field('foo'), $xhtml ); clone.yml100644001751001752 36712331714662 20616 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/repeatable--- auto_fieldset: 1 elements: - type: Hidden name: count - type: Repeatable nested_name: rep increment_field_names: 1 counter_name: count elements: - name: foo - name: bar constraints: - Required force_errors000755001751001752 012331714662 17233 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregateequal.t100644001751001752 463312331714662 20675 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/force_errorsuse strict; use warnings; use Test::More tests => 31; use HTML::FormFu; my $form = HTML::FormFu->new->force_errors(1); $form->element('Text')->name('foo')->constraint('Equal') ->others( [ 'bar', 'baz' ] ); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); # valid { $form->process( { foo => 'yada', bar => 'yada', baz => 'yada', } ); ok( $form->submitted_and_valid ); ok( !$form->has_errors('foo') ); ok( !$form->has_errors('bar') ); ok( !$form->has_errors('baz') ); ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } ); } # valid { $form->process( { foo => '', bar => '', baz => '', } ); ok( $form->submitted_and_valid ); ok( !$form->has_errors('foo') ); ok( !$form->has_errors('bar') ); ok( !$form->has_errors('baz') ); ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } ); } # valid { $form->process( { foo => [ 'a', 'b' ], bar => [ 'a', 'b' ], baz => [ 'b', 'a' ], } ); ok( $form->submitted_and_valid ); ok( !$form->has_errors('foo') ); ok( !$form->has_errors('bar') ); ok( !$form->has_errors('baz') ); ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } ); } # invalid { $form->process( { foo => 'yada', bar => 'yada', baz => 'x', } ); ok( !$form->submitted_and_valid ); ok( !$form->has_errors('foo') ); ok( !$form->has_errors('bar') ); ok( $form->has_errors('baz') ); ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } ); } # invalid { $form->process( { foo => [ 'a', 'b' ], bar => [ 'a', 'b' ], baz => ['a'], } ); ok( !$form->submitted_and_valid ); ok( !$form->has_errors('foo') ); ok( !$form->has_errors('bar') ); ok( $form->has_errors('baz') ); ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } ); } number.t100644001751001752 137012331714662 20726 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 8; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('Number'); # Valid { $form->process( { foo => 1, bar => 2, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } # "0" is valid { $form->process( { foo => 0, bar => 2, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'foo valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } file.yml100644001751001752 24712331714662 20675 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraints--- action: 'http://www.perl.org/test.cgi' elements: - type: File name: hello_world - type: File name: does_not_exist_gif constraints: - type: File length.t100644001751001752 121012331714662 20710 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Length')->min(3)->max(5); $form->element('Text')->name('bar')->constraint('Length')->min(3)->max(5); # Valid { $form->process( { foo => 'abc', bar => 'abcd', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'ab', bar => 'abcdef', } ); ok( !$form->valid('foo'), 'foo not valid' ); ok( !$form->valid('bar'), 'bar not valid' ); } element_class.t100644001751001752 130212331714662 20640 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; =pod The input class was getting " text" appended again. Fixed by cloning the elements in HTML::FormFu::result() =cut my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); my $xhtml = <
EOF # 1st result { $form->process( {} ); is( "$form", $xhtml, 'stringified form' ); } # 2nd result { $form->process( {} ); is( "$form", $xhtml, 'stringified form' ); } field_no_name.t100644001751001752 67112331714662 20571 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text'); $form->element('Text')->name('foo'); my $div = $form->element('Block'); $div->element('Text'); $div->element('Text')->name('bar'); $form->process( { foo => 1 } ); is( @{ $form->get_fields('foo') }, 1 ); { my $div = $form->get_element( { type => 'Block' } ); is( @{ $div->get_fields('bar') }, 1 ); } plugins000755001751001752 012331714662 16222 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregatestashvalid.t100644001751001752 45712331714662 20677 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/pluginsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/plugins/stashvalid.yml'); $form->process( { foo => 'a', bar => 'b', } ); is( $form->stash->{foo}, 'a' ); is( $form->stash->{bar}, undef ); callback.t100644001751001752 172412331714662 20627 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/inflatorsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; use lib 'lib'; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->inflator('Callback') ->callback( sub { return uc( $_[0] ) } ); $form->element('Text')->name('bar')->inflator('Callback') ->callback('InflatorCallback::my_def'); my $original_foo = "abc123"; my $inflated_foo = "ABC123"; my $original_bar = "abcdef"; my $inflated_bar = "ABCdef"; $form->process( { foo => $original_foo, bar => $original_bar, } ); # foo is changed is( $form->param('foo'), $inflated_foo, 'foo inflated' ); is( $form->params->{foo}, $inflated_foo, 'foo inflated' ); # bar is changed is( $form->param('bar'), $inflated_bar, 'bar inflated' ); is( $form->params->{bar}, $inflated_bar, 'bar inflated' ); { package InflatorCallback; use strict; use warnings; sub my_def { my ($value) = @_; $value =~ tr/abc/ABC/; return $value; } } htmlescape.t100644001751001752 66712331714662 20654 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->filter('HTMLEscape'); my $original_foo = qq{&escape "this"}; my $filtered_foo = "&escape "this""; $form->process( { foo => $original_foo, } ); # foo is filtered is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); regex_eval.t100644001751001752 110112331714662 20650 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/filters/regex_eval.yml'); { $form->process( { foo => '.4.5 ', } ); is( $form->param_value('foo'), '4.5' ); } { $form->process( { foo => '4.', } ); is( $form->param_value('foo'), '4' ); } { $form->process( { foo => '4.0', } ); is( $form->param_value('foo'), '4.0' ); } # doesn't filter, as it doesn't match the regex { $form->process( { foo => ' a', } ); is( $form->param_value('foo'), ' a' ); } nonnumeric.t100644001751001752 64512331714662 20700 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->filter('NonNumeric'); my $original_foo = " 0123-4567 (8a9)"; my $filtered_foo = "0123456789"; $form->process( { foo => $original_foo, } ); # foo is filtered is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); whitespace.t100644001751001752 63012331714662 20651 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->filter('Whitespace'); my $original_foo = "Foo Bar"; my $filtered_foo = "FooBar"; $form->process( { foo => $original_foo, } ); # foo is filtered is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); deflators000755001751001752 012331714662 16524 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregatecallback.t100644001751001752 200512331714662 20602 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/deflatorsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; use lib 'lib'; my $original_foo = "abc123"; my $deflated_foo = "ABC123"; my $original_bar = "abcdef"; my $deflated_bar = "ABCdef"; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element( { name => 'foo', default => $original_foo, deflator => { type => 'Callback', callback => sub { return uc( $_[0] ) }, }, } ); $form->element( { name => 'bar', default => $original_bar, deflator => { type => 'Callback', callback => 'DeflatorCallback::my_def', }, } ); $form->process; like( $form->get_field('foo'), qr/\Q$deflated_foo/ ); like( $form->get_field('bar'), qr/\Q$deflated_bar/ ); { package DeflatorCallback; use strict; use warnings; sub my_def { my ($value) = @_; $value =~ tr/abc/ABC/; return $value; } } error_message.t100644001751001752 137112331714662 20670 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->form_error_message_loc('form_error_message'); my $field = $form->element('Text'); $field->name('foo'); $field->constraint('Number'); unlike( "$form", qr/there were errors/i ); $form->process( { foo => '1', } ); unlike( "$form", qr/there were errors/i ); $form->process( { foo => 'a', } ); my $xhtml = <
There were errors with your submission, see below for details
This field must be a number
EOF is( "$form", $xhtml ); auto_fieldset.t100644001751001752 134612331714662 20664 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->auto_fieldset( { id => 'fs' } ); $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); my $fs = $form->element('Fieldset'); $fs->element('Text')->name('baz'); $form->element('Text')->name('yam'); # xhtml output my $xhtml = <
EOF is( "$form", $xhtml ); get_inflators.t100644001751001752 130512331714662 20670 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 7; use HTML::FormFu; my $form = HTML::FormFu->new; my $e1 = $form->element('Text')->name('foo'); my $e2 = $form->element('Text')->name('bar'); $form->inflator( DateTime => 'foo', 'bar' ); { my $i = $form->get_inflators; is( @$i, 2 ); } { my $i = $form->get_inflators('foo'); is( @$i, 1 ); } { my $i = $e1->get_inflators; is( @$i, 1 ); } { my $i = $e1->get_inflators( { name => 'foo' } ); is( @$i, 1 ); } { my $i = $e2->get_inflators; is( @$i, 1 ); } { my $i = $e2->get_inflators( { name => 'bar' } ); is( @$i, 1 ); } { my $i = $e2->get_inflators( { name => 'foo' } ); is( @$i, 0 ); } get_deflators.t100644001751001752 130512331714662 20652 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 7; use HTML::FormFu; my $form = HTML::FormFu->new; my $e1 = $form->element('Text')->name('foo'); my $e2 = $form->element('Text')->name('bar'); $form->deflator( Strftime => 'foo', 'bar' ); { my $d = $form->get_deflators; is( @$d, 2 ); } { my $d = $form->get_deflators('foo'); is( @$d, 1 ); } { my $d = $e1->get_deflators; is( @$d, 1 ); } { my $d = $e1->get_deflators( { name => 'foo' } ); is( @$d, 1 ); } { my $d = $e2->get_deflators; is( @$d, 1 ); } { my $d = $e2->get_deflators( { name => 'bar' } ); is( @$d, 1 ); } { my $i = $e2->get_deflators( { name => 'foo' } ); is( @$i, 0 ); } hidden_fields.t100644001751001752 57412331714662 20600 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Hidden')->name('foo'); $form->element('Hidden')->name('bar'); my $xhtml = qq{}; is( $form->hidden_fields, $xhtml ); insert_before.t100644001751001752 142012331714662 20654 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 7; use HTML::FormFu; { my $form = HTML::FormFu->new; my $e1 = $form->element('Text')->name('foo'); my $e2 = $form->element('Hidden')->name('foo'); my $e3 = $e1->clone; $form->insert_before( $e3, $e1 ); my $elems = $form->get_elements; is( scalar(@$elems), 3 ); ok( $elems->[0] == $e3 ); ok( $elems->[1] == $e1 ); ok( $elems->[2] == $e2 ); } # ensure elements only occur once { my $form = HTML::FormFu->new; my $e1 = $form->element( { name => 'foo' } ); my $e2 = $form->element( { name => 'bar' } ); $form->insert_before( $e2, $e1 ); my $elems = $form->get_elements; is( scalar(@$elems), 2 ); ok( $elems->[0] == $e2 ); ok( $elems->[1] == $e1 ); } QueryType000755001751001752 012331714662 17031 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuCGI.pm100644001751001752 440412331714662 20133 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/QueryTypepackage HTML::FormFu::QueryType::CGI; $HTML::FormFu::QueryType::CGI::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Upload'; use HTTP::Headers; use Scalar::Util qw( blessed ); sub parse_uploads { my ( $class, $form, $name ) = @_; my $query = $form->query; my @params = $query->param($name); my @new; for my $param (@params) { if ( blessed $param ) { my $filename = $param; $param = $class->new( { _param => $param, filename => sprintf( "%s", $filename ), parent => $form, # TODO: for now, parent points to the form # pointing to a field will require handling multiple # fields of the same name # if fixed, other QueryTypes and MultiForm will need updating } ); my $headers = HTTP::Headers->new( %{ $query->uploadInfo($filename) } ); $param->headers($headers); $param->size( $headers->content_length ); $param->type( $headers->content_type ); } push @new, $param; } return if !@new; return @new == 1 ? $new[0] : \@new; } sub fh { my ($self) = @_; return $self->_param; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::QueryType::CGI - uploaded file =head1 METHODS =head2 headers As of L version C<0.02004>, returns a L object. - Previously returned a hashref of values. =head2 filename Returns the browser-submitted filename of the local file. =head2 fh Returns a read-only filehandle. =head2 slurp Returns the contents of the uploaded file. =head2 size A shortcut for C<< $upload->headers->content_length >>. Returns the size of the uploaded file in bytes. =head2 type A shortcut for C<< $upload->headers->content_type >>. Returns the browser-submitted Content-Type of the uploaded file. =head1 SEE ALSO Is a sub-class of, and inherits methods from L L, L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Blank.pm100644001751001752 176712331714662 20213 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Blank; $HTML::FormFu::Element::Blank::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; use HTML::FormFu::Constants qw( $EMPTY_STR ); after BUILD => sub { my $self = shift; $self->label_tag($EMPTY_STR); #$self->field_type( $EMPTY_STR ); $self->render($EMPTY_STR); return; }; sub field_tag { return $EMPTY_STR; } override render => sub { return $EMPTY_STR; }; around render_data_non_recursive => sub { return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Blank - blank element =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Radio.pm100644001751001752 167312331714662 20216 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Radio; $HTML::FormFu::Element::Radio::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element::Checkbox'; use HTML::FormFu::Constants qw( $EMPTY_STR ); __PACKAGE__->mk_output_accessors(qw( default )); after BUILD => sub { my $self = shift; $self->field_type('radio'); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Radio - Radio form field =head1 SYNOPSIS my $element = $form->element( Radio => 'foo' ); =head1 DESCRIPTION Radio form field. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Multi.pm100644001751001752 1161512331714662 20267 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Multi; $HTML::FormFu::Element::Multi::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element::Block'; with 'HTML::FormFu::Role::Element::Field', 'HTML::FormFu::Role::Element::SingleValueField'; use HTML::FormFu::Util qw( append_xml_attribute xml_escape process_attrs _parse_args _get_elements _filter_components ); use Clone (); after BUILD => sub { my $self = shift; $self->comment_attributes( {} ); $self->container_attributes( {} ); $self->label_attributes( {} ); $self->layout_field_filename('field_layout_multi_field'); $self->label_tag('label'); return; }; sub get_fields { my $self = shift; my %args = _parse_args(@_); my $f = $self->SUPER::get_fields(@_); unshift @$f, $self; return _get_elements( \%args, $f ); } sub get_deflators { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_deflators }; push @x, map { @{ $_->get_deflators(@_) } } @{ $self->_elements }; return _filter_components( \%args, \@x ); } sub get_filters { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_filters }; push @x, map { @{ $_->get_filters(@_) } } @{ $self->_elements }; return _filter_components( \%args, \@x ); } sub get_constraints { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_constraints }; push @x, map { @{ $_->get_constraints(@_) } } @{ $self->_elements }; return _filter_components( \%args, \@x ); } sub get_inflators { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_inflators }; push @x, map { @{ $_->get_inflators(@_) } } @{ $self->_elements }; return _filter_components( \%args, \@x ); } sub get_validators { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_validators }; push @x, map { @{ $_->get_validators(@_) } } @{ $self->_elements }; return _filter_components( \%args, \@x ); } sub get_transformers { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_transformers }; push @x, map { @{ $_->get_transformers(@_) } } @{ $self->_elements }; return _filter_components( \%args, \@x ); } sub get_errors { my $self = shift; my %args = _parse_args(@_); my @x = @{ $self->_errors }; push @x, map { @{ $_->get_errors(@_) } } @{ $self->_elements }; _filter_components( \%args, \@x ); if ( !$args{forced} ) { @x = grep { !$_->forced } @x; } return \@x; } sub clear_errors { my ($self) = @_; $self->_errors( [] ); map { $_->clear_errors } @{ $self->_elements }; return; } sub render_data { my $self = shift; my $render = $self->SUPER::render_data(@_); map { delete $_->{container_tag} } @{ $render->{elements} || [] }; return $render; } sub render_data_non_recursive { my $self = shift; my $render = $self->SUPER::render_data_non_recursive(@_); append_xml_attribute( $render->{attributes}, 'class', 'elements' ); return $render; } sub _parse_layout_field { my ( $self, $render ) = @_; my @html = ( sprintf "", process_attrs( $render->{attributes} ), ); for my $elem ( @{ $self->get_elements } ) { my $render = $elem->render_data; next if !defined $render; $render->{container_tag} = undef; push @html, $elem->string( { render_data => $render, layout => $elem->multi_layout } ); } push @html, ""; return join "\n", @html; } sub clone { my $self = shift; my $clone = $self->SUPER::clone(@_); $clone->comment_attributes( Clone::clone( $self->comment_attributes ) ); $clone->container_attributes( Clone::clone( $self->container_attributes ) ); $clone->label_attributes( Clone::clone( $self->label_attributes ) ); return $clone; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Multi - Combine multiple fields in a single element =head1 SYNOPSIS my $e = $form->element( Multi => 'foo' ); =head1 DESCRIPTION Combine multiple form fields in a single logical element. Non-field elements cannot be added as children of the Multi element. =head1 RENDERING NOTES If the Multi element is rendered with the default 'string' render-method, all child fields will be rendered with the 'string' render-method, regardless of their L value. Likewise, if the Multi element is rendered with the 'tt' render-method, all child fields will be rendered with the 'tt' render-method, regardless of their L value. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Block.pm100644001751001752 2451512331714662 20232 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Block; $HTML::FormFu::Element::Block::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::CreateChildren', 'HTML::FormFu::Role::GetProcessors', 'HTML::FormFu::Role::ContainsElements', 'HTML::FormFu::Role::ContainsElementsSharedWithField', 'HTML::FormFu::Role::FormAndBlockMethods', 'HTML::FormFu::Role::FormBlockAndFieldMethods'; use HTML::FormFu::Constants qw( $EMPTY_STR ); use HTML::FormFu::Util qw( _get_elements xml_escape process_attrs ); use Clone (); use List::MoreUtils qw( uniq ); use Carp qw( croak ); has tag => ( is => 'rw', traits => ['FormFuChained'] ); has nested_name => ( is => 'rw', traits => ['FormFuChained'] ); has original_nested_name => ( is => 'rw', traits => ['FormFuChained'] ); has auto_block_id => ( is => 'rw', traits => ['FormFuChained'] ); has _elements => ( is => 'rw', default => sub { [] }, lazy => 1, isa => 'ArrayRef', ); __PACKAGE__->mk_output_accessors(qw( content )); *elements = \&element; *constraints = \&constraint; *deflators = \&deflator; *filters = \&filter; *inflators = \&inflator; *validators = \&validator; *transformers = \&transformer; *plugins = \&plugin; after BUILD => sub { my ( $self, $args ) = @_; $self->filename('block'); $self->tag('div'); $self->is_block(1); return; }; sub _single_plugin { my ( $self, $arg ) = @_; if ( !ref $arg ) { $arg = { type => $arg }; } elsif ( ref $arg eq 'HASH' ) { $arg = {%$arg}; # shallow clone } else { croak 'invalid args'; } my @names = map { ref $_ ? @$_ : $_ } grep {defined} ( delete $arg->{name}, delete $arg->{names} ); if ( !@names ) { @names = uniq grep {defined} map { $_->nested_name } @{ $self->get_fields }; } croak "no field names to add plugin to" if !@names; my $type = delete $arg->{type}; my @return; for my $x (@names) { for my $field ( @{ $self->get_fields( { nested_name => $x } ) } ) { my $new = $field->_require_plugin( $type, $arg ); push @{ $field->_plugins }, $new; push @return, $new; } } return @return; } sub pre_process { my ($self) = @_; map { $_->pre_process } @{ $self->_elements }; return; } sub process { my ($self) = @_; map { $_->process } @{ $self->_elements }; return; } sub post_process { my ($self) = @_; map { $_->post_process } @{ $self->_elements }; return; } sub render_data { my $self = shift; my $render = $self->render_data_non_recursive( { @_ ? %{ $_[0] } : () } ); $render->{elements} = [ map { $_->render_data } @{ $self->_elements } ]; return $render; } sub render_data_non_recursive { my ( $self, $args ) = @_; my $render = $self->SUPER::render_data_non_recursive( { tag => $self->tag, content => xml_escape( $self->content ), $args ? %$args : (), } ); return $render; } sub prepare_id { my ( $self, $render ) = @_; if ( !defined $render->{attributes}{id} && defined $self->auto_block_id && length $self->auto_block_id ) { my $form_name = defined $self->form->id ? $self->form->id : $EMPTY_STR; my %string = ( f => $form_name, ); my $id = $self->auto_block_id; $id =~ s/%([f])/$string{$1}/g; if ( defined( my $count = $self->repeatable_count ) ) { $id =~ s/%r/$count/g; } $render->{attributes}{id} = $id; } return; } sub string { my ( $self, $args ) = @_; $args ||= {}; my $render = exists $args->{render_data} ? $args->{render_data} : $self->render_data_non_recursive; # start_block template my $html = ''; if ( defined $render->{tag} ) { $html .= sprintf "<%s%s>", $render->{tag}, process_attrs( $render->{attributes} ), ; } if ( defined $render->{legend} ) { $html .= sprintf "\n%s", defined( $render->{legend_attributes} ) ? process_attrs( $render->{legend_attributes} ) : '', $render->{legend}; } # block template $html .= "\n"; if ( defined $render->{content} ) { $html .= sprintf "%s\n", $render->{content}; } else { for my $elem ( @{ $self->get_elements } ) { # call render, so that child elements can use a different renderer my $elem_html = $elem->render; # skip Blank fields if ( length $elem_html ) { $html .= $elem_html . "\n"; } } } # end_block template if ( defined $render->{tag} ) { $html .= sprintf "", $render->{tag}; } return $html; } sub start { my ($self) = @_; return $self->tt( { filename => 'start_block', render_data => $self->render_data_non_recursive, } ); } sub end { my ($self) = @_; return $self->tt( { filename => 'end_block', render_data => $self->render_data_non_recursive, } ); } sub clone { my $self = shift; my $clone = $self->SUPER::clone(@_); $clone->_elements( [ map { $_->clone } @{ $self->_elements } ] ); map { $_->parent($clone) } @{ $clone->_elements }; $clone->default_args( Clone::clone( $self->default_args ) ); return $clone; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Block - Block element =head1 SYNOPSIS --- elements: - type: Block elements: - type: Text name: foo - type: Block tag: span content: Whatever =head1 DESCRIPTION Block element which may contain other elements. =head1 METHODS =head2 tag Specifies which tag name should be used to render the block. Default Value: 'div' =head2 content If L is set, it is used as the block's contents, and any attached elements are ignored. =head2 content_xml Arguments: $string If you don't want the content to be XML-escaped, use the L method instead of L. =head2 content_loc Arguments: $localization_key To set the content to a localized string, set L to a key in your L10N file instead of using L. =head2 elements See L for details. =head2 element See L for details. =head2 deflators See L for details. =head2 deflator See L for details. =head2 filters See L for details. =head2 filter See L for details. =head2 constraints See L for details. =head2 constraint See L for details. =head2 inflators See L for details. =head2 inflator See L for details. =head2 validators See L for details. =head2 validator See L for details. =head2 transformers See L for details. =head2 transformer See L for details. =head2 auto_datalist_id See L for details. =head1 CSS CLASSES =head2 auto_id See L for details. =head2 auto_block_id Arguments: [$string] If set, the Block will be given an auto-generated L attribute, if it doesn't have one already. The following character substitution will be performed: C<%f> will be replaced by L<< $form->id|/id >>, C<%r> will be replaced by L<< $block->repeatable_count|HTML::FormFu::Element::Repeatable/repeatable_count >>. Default Value: not defined Unlike most other auto_* methods, this is not an 'inherited accessor'. =head2 auto_label See L for details. =head2 auto_error_class See L for details. =head2 auto_error_message See L for details. =head2 auto_constraint_class See L for details. =head2 auto_inflator_class See L for details. =head2 auto_validator_class See L for details. =head2 auto_transformer_class See L for details. =head2 default_args See L for details. =head1 RENDERING =head2 start =head2 end =head1 INTROSPECTION =head2 get_elements See L for details. =head2 get_element See L for details. =head2 get_all_elements See L for details. =head2 get_fields See L for details. =head2 get_field See L for details. =head2 get_deflators See L for details. =head2 get_deflator See L for details. =head2 get_filters See L for details. =head2 get_filter See L for details. =head2 get_constraints See L for details. =head2 get_constraint See L for details. =head2 get_inflators See L for details. =head2 get_inflator See L for details. =head2 get_validators See L for details. =head2 get_validator See L for details. =head2 get_transformers See L for details. =head2 get_transformer See L for details. =head2 get_errors See L for details. =head2 clear_errors See L for details. =head1 SEE ALSO Base-class for L. Is a sub-class of, and inherits methods from L L =head1 REMOVED METHODS =head2 element_defaults Has been removed; use L instead. =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Image.pm100644001751001752 174512331714662 20202 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Image; $HTML::FormFu::Element::Image::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element::Button'; __PACKAGE__->mk_attr_accessors(qw( src width height )); after BUILD => sub { my $self = shift; $self->field_type('image'); if ( !defined $self->src ) { $self->src(''); } return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Image - Image button form field =head1 SYNOPSIS $e = $form->element( Image => 'foo' ); =head1 DESCRIPTION Image button form field. =head1 METHODS =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Label.pm100644001751001752 524112331714662 20172 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Label; $HTML::FormFu::Element::Label::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends "HTML::FormFu::Element"; with 'HTML::FormFu::Role::Element::Field', 'HTML::FormFu::Role::Element::SingleValueField', 'HTML::FormFu::Role::Element::Coercible'; use HTML::FormFu::Util qw( process_attrs ); use List::MoreUtils qw( none ); has field_type => ( is => 'rw', traits => ['FormFuChained'] ); has tag => ( is => 'rw', default => 'span', lazy => 1, traits => ['FormFuChained'], ); after BUILD => sub { my $self = shift; $self->layout_field_filename('field_layout_label_field'); $self->non_param(1); #$self->field_type('label'); $self->model_config->{read_only} = 1; return; }; sub _string_field { my ( $self, $render ) = @_; my $html .= "<" . $self->tag; $html .= sprintf "%s", process_attrs( $render->{attributes} || {} ); if ( defined $render->{nested_name} ) { $html .= sprintf qq{ name="%s"}, $render->{nested_name}; } $html .= ">"; if ( defined $render->{value} ) { $html .= sprintf qq{%s}, $render->{value}; } $html .= "tag . ">"; return $html; } sub process_input { my ( $self, $input ) = @_; my $form = $self->form; my $name = $self->nested_name; if ( $form->submitted && $form->nested_hash_key_exists( $input, $name ) ) { my @fields = @{ $form->get_fields( { nested_name => $name } ) }; if ( none { $_ == $self } @fields ) { $form->delete_nested_hash_key( $input, $name ); } } return; } sub render_data_non_recursive { my ( $self, $args ) = @_; my $render = $self->SUPER::render_data_non_recursive( { tag => $self->tag, $args ? %$args : (), } ); return $render; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Label - field for displaying only =head1 DESCRIPTION This element displays a value. This is useful if you use a model like L and want to display a value from the database. The value of this field cannot be set by the client. See L for more information on read only fields. =head1 METHODS =head2 tag Set the tag for this element. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L L =head1 AUTHOR Moritz Onken, C<< onken at houseofdesign.de >> =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Email.pm100644001751001752 223512331714662 20202 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Email; $HTML::FormFu::Element::Email::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; after BUILD => sub { my $self = shift; $self->field_type('email'); $self->constraint('Email'); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Email - HTML5 email form field =head1 SYNOPSIS my $element = $form->element( Email => 'foo' ); # no need to add a separate Constraint::Email =head1 DESCRIPTION HTML5 email form field which provides native client-side validation in modern browsers. Creates an input field with C<>. This element automatically adds an L, so you don't have to. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L. L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Reset.pm100644001751001752 155412331714662 20240 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Reset; $HTML::FormFu::Element::Reset::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element::Button'; after BUILD => sub { my $self = shift; $self->field_type('reset'); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Reset - Reset button form field =head1 SYNOPSIS $e = $form->element( Reset => 'foo' ); =head1 DESCRIPTION Reset button form field. =head1 METHODS =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode.pm100644001751001752 431312331714662 20203 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Filterpackage HTML::FormFu::Filter::Encode; $HTML::FormFu::Filter::Encode::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Filter'; use Encode qw(encode decode FB_CROAK); has encode_to => ( is => 'rw', traits => ['FormFuChained'] ); has _candidates => ( is => 'rw' ); sub filter { my ( $self, $value ) = @_; return if !defined $value; my $utf8 = $self->decode_to_utf8($value); die "HTML::FormFu::Filter::Encode: Unable to decode given string to utf8" if !defined $utf8; return $self->encode_from_utf8($utf8); } sub get_candidates { my ($self) = @_; my $ret = $self->_candidates; if ( $ret && wantarray ) { return @$ret; } return $ret; } sub candidates { my ( $self, @candidates ) = @_; if ( @_ > 1 ) { if ( ref $candidates[0] eq 'ARRAY' ) { $self->_candidates( $candidates[0] ); } else { $self->_candidates( [@candidates] ); } } return $self; } sub decode_to_utf8 { my ( $self, $value ) = @_; my $ret; foreach my $candidate ( $self->get_candidates ) { eval { $ret = decode( $candidate, $value, FB_CROAK ) }; if ( !$@ ) { last; } } return $ret; } sub encode_from_utf8 { my ( $self, $value ) = @_; my $enc = $self->encode_to; if ( !$enc ) { return $value; } return encode( $enc, $value ); } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Filter::Encode - Encode/Decode Submitted Values =head1 SYNOPSIS # in your config: elements: - type: Text filters: - type: Encode candidates: - utf8 - Hebrew # if you want to encode the decoded string to something else elements: - type: Text filters: - type: Encode candidates: - utf8 - Hebrew encode_to: UTF-32BE =head1 AUTHOR Copyright (c) 2007 Daisuke Maki Edaisuke@endeworks.jpE All rights reserved. =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Populate.pm100644001751001752 431112331714662 20251 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Rolepackage HTML::FormFu::Role::Populate; $HTML::FormFu::Role::Populate::VERSION = '2.01'; use Moose::Role; use Scalar::Util qw( reftype ); use Carp qw( croak ); after BUILD => sub { my ( $self, $args ) = @_; $args ||= {}; # get args handled by Moose so they aren't set twice my %init_args = map { $_->{init_arg} => 1 } grep { defined $_->{init_arg} } $self->meta->get_all_attributes; # remove defaults set in HTML::FormFu::BUILD because they need to be set for a third time delete @init_args{ keys %{$HTML::FormFu::build_defaults} }; my %args = map { $_ => $args->{$_} } grep { !exists $init_args{$_} } keys %$args; $self->populate( \%args ); return; }; sub populate { my ( $self, $arg_ref ) = @_; croak "argument to populate() must be a hash-ref" if reftype($arg_ref) ne 'HASH'; # shallow clone the args so we don't stomp on them my %args = %$arg_ref; # we have to handle element_defaults seperately, as it is no longer a # simple hash key if ( exists $args{element_defaults} ) { $self->element_defaults( delete $args{element_defaults} ); } # handle any 'roles' first my $roles = delete $args{roles}; # notes for @defer_keys... # 'options', 'values', 'value_range' is for _Group elements, # to ensure any 'empty_first' value gets set first my @defer_keys = qw( default_args auto_fieldset load_config_file element elements default_values filter filters constraint constraints inflator inflators deflator deflators query validator validators transformer transformers plugins options values value_range ); my %defer; for (@defer_keys) { $defer{$_} = delete $args{$_} if exists $args{$_}; } eval { if ( $roles ) { $self->roles( $roles ); } map { $self->$_( delete $args{$_} ) } keys %args; map { $self->$_( $defer{$_} ) } grep { exists $defer{$_} } @defer_keys; }; croak $@ if $@; return $self; } 1; Model000755001751001752 012331714662 16122 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuHashRef.pm100644001751001752 3051212331714662 20161 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Modelpackage HTML::FormFu::Model::HashRef; $HTML::FormFu::Model::HashRef::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Model'; use Hash::Flatten; use Scalar::Util qw(blessed); has flatten => ( is => 'rw' ); has options => ( is => 'rw' ); has _repeatable => ( is => 'rw', traits => ['FormFuChained'] ); has _multi => ( is => 'rw', traits => ['FormFuChained'] ); has deflators => ( is => 'rw', default => 1, lazy => 1, traits => ['FormFuChained'], ); has inflators => ( is => 'rw', default => 1, lazy => 1, traits => ['FormFuChained'], ); sub default_values { my ( $self, $data ) = @_; map { $_->default(undef) } ( grep { $_->is_field } @{ $self->form->get_all_elements } ); $self->_default_values( $self->form, $data ); return $self; } sub _default_values { my ( $self, $form, $data ) = @_; my $elements = $form->get_elements; foreach my $element ( @{$elements} ) { my $name = $element->name || ""; my $nested_name = $element->nested_name || ""; $name =~ s/_\d+$// if ($name); if ( $element->is_repeatable ) { my $value = $data->{$name} || $data->{$nested_name}; unless ($value) { $element->repeat(0); map { $element->remove_element($_) } @{ $element->get_elements }; next; } my $k = scalar @{$value}; $element->repeat($k); my $childs = $element->get_elements; for ( my $i = 0; $i < $k; $i++ ) { $self->_default_values( $childs->[$i], $value->[$i] ); } } elsif ( $element->is_block && $element->is_field ) { # is a Multi element ref $data->{$name} eq "HASH" ? $self->_default_values( $element, $data->{$name} ) : $element->default( $data->{$name} ); } elsif ( $element->is_block ) { $self->_default_values( $element, $nested_name ? $data->{$nested_name} : $data ); } else { if ( $self->inflators && @{ $element->get_inflators } > 0 ) { my @inflators = @{ $element->get_inflators }; map { $element->default( $_->process( $data->{$name} ) ) } @inflators; } else { $element->default( $data->{$name} ); } } } return $self; } sub update { shift->create(@_) } sub create { my $self = shift; if ( $self->form->submitted ) { my $input = _escape_hash( $self->form->input ); my $hf = new Hash::Flatten( { ArrayDelimiter => '_', HashDelimiter => '.' } ); $input = _unescape_hash( $hf->unflatten( $self->form->input ) ); $self->default_values( $self->_unfold_repeatable( $self->form, $input ) ); } $self->form->render_data; my $obj = $self->_as_object_get( $self->form ); if ( $self->flatten ) { my $hf = new Hash::Flatten( { ArrayDelimiter => '_', HashDelimiter => '.' } ); $obj = $self->_unfold_repeatable( $self->form, $hf->flatten($obj) ); } return $obj; } sub _as_object_get { my $self = shift; my $form = shift; my $e = $form->get_all_elements; my $names = {}; foreach my $element ( @{$e} ) { my $name = $element->nested_name; next unless $name; next if ( $element->type eq "Multi" ); my $es_name = _escape_name($name); if ( $self->options && $element->can('_options') && @{ $element->_options } > 0 ) { my @options = @{ $element->_options }; my @values = ref $element->default eq "ARRAY" ? @{ $element->default } : $element->default; $names->{$es_name} = []; foreach my $value (@values) { my @option = grep { defined $value && $_->{value} eq $value } @options; unless (@option) { @options = map { @{ $_->{group} || [] } } @options; @option = grep { $_->{value} eq $value } @options; } my $obj = [ map { { value => $_->{value}, label => $_->{label} } } @option ]; push( @{ $names->{$es_name} }, $obj->[0] ) if $name; } $names->{$es_name} = $names->{$es_name}->[0] if scalar @values == 1; $names->{$es_name} ||= { value => undef, label => undef }; } elsif ( $element->is_field && $self->deflators ) { my $deflators = $element->get_deflators; $names->{$es_name} = $element->default if ( $element->can('default') ); map { $names->{$es_name} = $_->deflator( $names->{$es_name} ) } @{$deflators}; } else { $names->{$es_name} = $element->default if ( $element->can('default') ); } if ( blessed $names->{$es_name} ) { delete $names->{$es_name} } } my $hf = new Hash::Flatten( { ArrayDelimiter => '_' } ); return $self->_unfold_repeatable( $form, $self->flatten ? $names : $hf->unflatten($names) ); } sub _escape_hash { my $hash = shift; my $method = shift || \&_escape_name; return $hash unless ( ref $hash ); foreach my $k ( keys %$hash ) { my $v = delete $hash->{$k}; if ( ref $v eq 'HASH' ) { $hash->{ $method->($k) } = _escape_hash( $v, $method ); } elsif ( ref $v eq 'ARRAY' ) { $hash->{ $method->($k) } = [ map { _escape_hash( $_, $method ) } @$v ]; } else { $hash->{ $method->($k) } = $v; } } return $hash; } sub _unescape_hash { return _escape_hash( shift, \&_unescape_name ); } sub _escape_name { my $name = shift; $name =~ s/_/\\_/g; $name =~ s/\\(_\d+(\.|$))/$1/g; return $name; } sub _unescape_name { my $name = shift; $name =~ s/\\_/_/g; $name =~ s/\\\./\./g; return $name; } sub _unfold_repeatable { my $self = shift; my $form = shift; my $data = shift; return $data unless ( ref $data eq "HASH" ); my $new = {}; while ( my ( $k, $v ) = each %{$data} ) { my $key = _unescape_name($k); if ( $self->get_repeatable($key) ) { $new->{$key} = []; # iterate over all array elements # we ignore the first one (index 0) as it is undef as we start # counting the repeated element names with 1 and the automatic # from Hash::Flatten assumed 0 as first index while unflattening # the parameter names # Example: # $v = [ # undef, # { # 'foo' => 'bar', # 'id' => 1 # }, # { # 'foo' => 'baz', # 'id' => 2 # } # ]; for ( my $i = 1; $i < @{ $v || [] }; $i++ ) { # process all key value pairs in an array element while ( my ( $name, $values ) = each %{ $v->[$i] } ) { # add an empty hash to array of unfolded data if not already present push( @{ $new->{$key} }, {} ) unless $new->{$key}->[ $i - 1 ]; # store processed values $new->{$key}->[ $i - 1 ]->{$name} = $self->_unfold_repeatable( $form, $values ); } } } elsif ( $self->get_multi($key) && ref $v eq "ARRAY" ) { for ( @{ $v || [] } ) { $new->{$key} = $_; last if $new->{$key}; } } else { $new->{$key} = $self->_unfold_repeatable( $form, $v ); } } return $new; } sub get_multi { my $self = shift; my $element = shift; unless ( $self->_multi ) { my %multis = (); my $multis = $self->form->get_all_elements( { type => qr/Multi/ } ); foreach my $multi ( @{ $multis || [] } ) { my @multis; map { push( @multis, $_->name ) } @{ $multi->get_elements }; map { s/_\d+//; $multis{$_} = 1 } @multis; } $self->_multi( \%multis ); } return $self->_multi->{$element}; } sub get_repeatable { my $self = shift; my $element = shift; unless ( $self->_repeatable ) { my %rep = (); my $rep = $self->form->get_all_elements( { type => qr/Repeatable/ } ); # TODO - Mario Minati 19.05.2009 # use $_->delimiter to split the keys foreach my $rep_element ( @{ $rep || [] } ) { my $name = $rep_element->nested_name; die "A Repeatable element without a nested_name attribute cannot be handled by Model::HashRef" unless $name; $name =~ s/_\d+//; $rep{$name} = 1; } $self->_repeatable( \%rep ); } return $self->_repeatable->{$element}; } __PACKAGE__->meta->make_immutable; __END__ =head1 NAME HTML::FormFu::Model::HashRef - handle hashrefs =head1 SYNOPSIS --- elements: - user_id - user_name - type: Repeatable nested_name: addresses elements: - type: Hidden name: id - street $form->model('HashRef')->default_values( { user_id => 123, user_name => 'Hans', addresses => [ { id => 2, street => 'Somewhere' }, { id => 3, street => 'Somewhere Else' } ] } ); $form->default_model('HashRef'); my $hashref = $form->model->create(); # $hashref is very much the same as the hashref you passed to default_values() =head1 DESCRIPTION If you need the content of a formular as hashref or for processing with other modules like C you can use this model. =head1 METHODS =head2 create This method creates a hashref from a filled form. This form can be filled by calling L, default_values of any other model class (e. g. L) or by simply submitting the form. If L is true all deflators are processed (defaults to C<1>). If L is true the value of all elements which have options like L will be transformed. --- elements: - type: Select name: select options: - [1, "Foo"] - [2, "Bar"] If the value of C
EO_RENDER validators000755001751001752 012331714662 16711 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregatecallback.t100644001751001752 140712331714662 20774 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/validatorsuse strict; use warnings; # base the package name on the test file path # to stop 'redefined' warnings under Test::Aggregate::Nested package My::Validators::Callback; sub cb { my $value = shift; ::ok(1) if grep { $value eq $_ ? 1 : 0 } qw/ 1 0 a /; return 1; } package main; use Test::More tests => 5; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->validator('Callback') ->callback( \&My::Validators::Callback::cb ); $form->element('Text')->name('bar')->validator('Callback')->callback("My::Validators::Callback::cb"); # Valid { $form->process( { foo => 1, bar => [ 0, 'a', 'b' ], } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } radiogroup.t100644001751001752 601412331714662 21056 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 5; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); my $field1 = $form->element('Radiogroup')->name('foo')->value(2) ->options( [ [ 1 => 'One' ], [ 2 => 'Two' ] ] ); # add element to test non-reversed labels my $field2 = $form->element('Radiogroup')->name('foo2') ->options( [ [ 'a' => 'A' ], [ 'b' => 'B' ] ] )->reverse_group(0); # add more elements to test accessor output $form->element('Radiogroup')->name('foo3')->options( [ { label => 'Ein', value => 1 }, { label => 'Zwei', value => 2, attributes => { class => 'foobar' }, container_attributes => { class => 'item 2' } }, ] ); $form->element('Radiogroup')->name('bar')->values( [qw/ one two three /] ) ->value('two')->label('My Bar'); $form->process; my $field1_xhtml = qq{
}; is( "$field1", $field1_xhtml, 'basic radiogroup' ); my $field2_xhtml = qq{
}; is( "$field2", $field2_xhtml, 'radiogroup with reverse_group off' ); my $form_xhtml = < $field1_xhtml $field2_xhtml
My Bar
EOF is( "$form", $form_xhtml, 'stringified form' ); # With mocked basic query { $form->process( { foo => 1, bar => 'three', } ); my $foo_xhtml = qq{
}; is( $form->get_field('foo'), $foo_xhtml, 'radiogroup after query' ); my $bar_xhtml = qq{
My Bar
}; is( $form->get_field('bar'), $bar_xhtml, 'second radiogroup after query' ); } date_undef.t100644001751001752 105612331714662 21002 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->populate( { elements => [ { type => "Date", name => "foo", year => { list => [2009] }, default => '30-08-2009' } ] } ); $form->process; like( $form->render, qr/value="2009" selected="selected"/ ); $form->get_field('foo')->default(undef); like( $form->render, qr/value="2009">/ ); date_order.t100644001751001752 2177312331714662 21044 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 7; use HTML::FormFu; use DateTime; my $dt = DateTime->new( day => 6, month => 8, year => 2007 ); my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Date')->name('foo')->strftime("%m/%d/%Y") ->field_order( [qw/ month day year /] )->day( { prefix => '-- Day --', } ) ->month( { prefix => '-- Month --', short_names => 1, } )->year( { prefix => '-- Year --', list => [ 2007 .. 2017 ], } )->default($dt)->auto_inflate(1)->constraint('Required'); $form->element('Date')->name('bar')->default('14-08-2007') ->field_order( [qw/ year month day /] ) ->year( { list => [ 2007 .. 2017 ] } ); $form->process; is( "$form", <
HTML $form->process( { 'foo_day', 30, 'foo_month', 6, 'foo_year', 2007, 'bar_day', 1, 'bar_month', 7, 'bar_year', 2007, } ); ok( $form->submitted_and_valid ); my $foo = $form->param('foo'); my $bar = $form->param('bar'); isa_ok( $foo, 'DateTime' ); ok( !ref $bar ); is( $foo, "06/30/2007" ); is( $bar, "01-07-2007" ); is( "$form", <
HTML combobox.yml100644001751001752 15712331714662 21033 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elements--- elements: - type: ComboBox name: combo values: - one - two - three datetime.yml100644001751001752 72412331714662 21017 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elements--- elements: - type: DateTime name: foo strftime: '%m/%d/%Y %H:%M' day: prefix: '-- Day --' month: prefix: '-- Month --' short_names: 1 year: prefix: '-- Year --' list: [2007, 2008, 2009, 2010, 2011] auto_inflate: 1 constraints: - Required - type: DateTime name: bar default: '14-08-2007 01:30' year: list: [2007, 2008, 2009, 2010, 2011] text_title.t100644001751001752 112312331714662 21064 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use lib 't/lib'; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { localize_class => 'HTMLFormFu::I18N', tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' }, } ); $form->element('Text')->name('foo')->title('The Foo'); $form->element('Text')->name('bar')->title_loc('bar_title'); my $expected_form_xhtml = <
EOF is( "$form", $expected_form_xhtml ); javascript_src.t100644001751001752 147412331714662 21054 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->auto_fieldset(1); $form->javascript_src('/dojo.js'); $form->javascript('foo();'); my $xhtml = <
EOF is( "$form", $xhtml ); # multiple { $form->javascript_src( [qw{ /one.js /two.js }] ); my $xhtml = <
EOF is( "$form", $xhtml ); } default_values.t100644001751001752 77712331714662 21027 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo'); $form->element('Checkbox')->name('bar')->value('y'); $form->default_values( { foo => 'x', bar => 'y', } ); $form->process; like( $form->get_field('foo'), qr/value="x"/ ); like( $form->get_field('bar'), qr/value="y"/ ); like( $form->get_field('bar'), qr/checked="checked"/ ); get_constraint.t100644001751001752 124312331714662 21054 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('name'); $form->element('Text')->name('age'); $form->constraint( Required => 'name', 'age' ); $form->constraint( Word => 'name' ); $form->constraint( Number => 'age' ); { my @constraints = $form->get_constraint; is( @constraints, 1 ); } { my @constraints = $form->get_constraint('name'); is( @constraints, 1 ); } { my @constraints = $form->get_constraint( { name => 'age' } ); is( @constraints, 1 ); } { my @constraints = $form->get_constraint( { type => 'Number' } ); is( @constraints, 1 ); } Hidden.pm100644001751001752 167212331714662 20352 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Hidden; $HTML::FormFu::Element::Hidden::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; after BUILD => sub { my $self = shift; $self->field_type('hidden'); $self->container_tag(undef); $self->layout( [ 'field', ] ); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Hidden - Hidden form field =head1 SYNOPSIS my $e = $form->element( Hidden => 'foo' ); =head1 DESCRIPTION Hidden form field. =head1 METHODS =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Number.pm100644001751001752 344712331714662 20411 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Number; $HTML::FormFu::Element::Number::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element::Text'; after BUILD => sub { my $self = shift; $self->deflator('FormatNumber'); $self->filter('FormatNumber'); return; }; sub precision { my $self = shift; return $self->get_deflator( { type => 'FormatNumber' } )->precision(@_); } sub trailing_zeroes { my $self = shift; return $self->get_deflator( { type => 'FormatNumber' } ) ->trailing_zeroes(@_); } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Number - Number element with formatting =head1 SYNOPSIS --- elements: - type: Number locale: de_DE precision: 2 trailing_zeroes: 1 =head1 DESCRIPTION This element formats numbers according to the current locale. You can set this locale either by setting C<< $form->locale >> or by setting the element's locale. If none of them is set the element uses the system's locale. =head1 METHODS =head2 locale Set the locale for this element. The format of the number is chosen according to this locale. =head2 precision Set the precision for the number. Defaults to C<2>. =head2 trailing_zeroes If this is set to C<1> the number has trailing zeroes. Defaults to C<0>. =head2 CHANGED BEHAVIOUR AS OF VERSION 0.09011 Previous to version 0.09011, this element generated an input field with C attribute which was not valid xhtml. Neither was the formatted numbers valid html5 - which expects the value to be a floating-point number. This element now generates a C attribute. =head1 SEE ALSO L L L =head1 AUTHOR Moritz Onken C< onken at houseofdesign.de > Submit.pm100644001751001752 157112331714662 20420 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Submit; $HTML::FormFu::Element::Submit::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element::Button'; after BUILD => sub { my $self = shift; $self->field_type('submit'); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Submit - Submit button form field =head1 SYNOPSIS $element = $form->element( Submit => 'foo' ); =head1 DESCRIPTION Submit button form field. =head1 METHODS =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Button.pm100644001751001752 200312331714662 20417 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Button; $HTML::FormFu::Element::Button::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; after BUILD => sub { my ( $self, $args ) = @_; $self->field_type('button'); $self->force_default(1); return; }; __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Button - Button form field =head1 SYNOPSIS $e = $form->element( Button => 'foo' ); =head1 DESCRIPTION Button form field, and base-class for L, L, L =head1 METHODS =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Select.pm100644001751001752 725112331714662 20375 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Select; $HTML::FormFu::Element::Select::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Group'; use HTML::FormFu::Constants qw( $EMPTY_STR ); use HTML::FormFu::Util qw( append_xml_attribute process_attrs ); use List::MoreUtils qw( any ); __PACKAGE__->mk_attr_accessors(qw( multiple size )); after BUILD => sub { my $self = shift; $self->layout_field_filename('field_layout_select_field'); $self->multi_value(1); return; }; sub _prepare_attrs { my ( $self, $submitted, $value, $default, $option ) = @_; if ( $submitted && defined $value && (ref $value eq 'ARRAY' ? any { $_ eq $option->{value} } @$value : $value eq $option->{value} ) ) { $option->{attributes}{selected} = 'selected'; } elsif ($submitted && $self->retain_default && ( !defined $value || $value eq $EMPTY_STR ) && $self->value eq $option->{value} ) { $option->{attributes}{selected} = 'selected'; } elsif ($submitted) { delete $option->{attributes}{selected}; } elsif ( defined $default && (ref $default eq 'ARRAY' ? any { $_ eq $option->{value} } @$default : $default eq $option->{value} ) ) { $option->{attributes}{selected} = 'selected'; } return; } sub _string_field { my ( $self, $render ) = @_; # select_tag template my $html .= sprintf qq{"; return $html; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Select - Select form field =head1 SYNOPSIS YAML config: --- elements: - type: Select name: sex options: - [ 'm', 'Male' ] - [ 'f', 'Female' ] =head1 DESCRIPTION Select form field. Supports optgroups, see L for details. =head1 METHODS =head2 options See L. =head2 values See L. =head2 value_range See L. =head2 empty_first See L. =head2 empty_first_label See L. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Constraint000755001751001752 012331714662 17206 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuSet.pm100644001751001752 231012331714662 20433 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Constraintpackage HTML::FormFu::Constraint::Set; $HTML::FormFu::Constraint::Set::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Constraint'; use Clone (); has set => ( is => 'rw', traits => ['FormFuChained'] ); sub constrain_value { my ( $self, $value ) = @_; return 1 if !defined $value || $value eq ''; my $set = $self->set; my %set = map { $_ => 1 } @$set; return exists $set{$value}; } sub clone { my $self = shift; my $clone = $self->SUPER::clone(@_); if ( $self->set ) { $clone->set( Clone::clone( $self->set ) ); } return $clone; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Constraint::Set - Set of Values Constraint =head1 SYNOPSIS type: Set set: [yes, no] =head1 DESCRIPTION The input value must be in the specified set of values. =head1 METHODS =head2 set Arguments: \@allowed_values =head1 SEE ALSO Is a sub-class of, and inherits methods from L L =head1 AUTHOR Carl Franks C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut HasParent.pm100644001751001752 47712331714662 20336 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Rolepackage HTML::FormFu::Role::HasParent; $HTML::FormFu::Role::HasParent::VERSION = '2.01'; use Moose::Role; sub BUILD { my ( $self, $args ) = @_; # Moose's new() only handles attributes - not methods if ( exists $args->{parent} ) { $self->parent( delete $args->{parent} ); } return; } 1; DBICUniqueFake.pm100644001751001752 46612331714662 20411 0ustar00carlcarl000000000000HTML-FormFu-2.01/t/lib/HTMLFormFupackage HTMLFormFu::DBICUniqueFake; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Constraint'; has id_field => ( is => 'rw', traits => ['FormFuChained'] ); sub constrain_value { my ( $self, $value ) = @_; return 1 if !defined $value || $value eq ''; return 1; } 1; 03podcoverage.t100644001751001752 35712331714662 21034 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/tuse strict; use warnings; use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_coverage_ok(); view_TT-Alloy.t100644001751001752 14312331714662 21023 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/tuse strict; use warnings; use Test::More tests => 1; BEGIN { use_ok 'unicode::View::TT::Alloy' } input100644001751001752 7612331714662 21264 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/root/formfu[% WRAPPER field %][% INCLUDE $self.field_filename %][% END %]field100644001751001752 145512331714662 21252 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/root/formfu[% IF self.container_tag.defined %]<[% self.container_tag %][% process_attrs(self.container_attributes) %]>[% END %][% IF self.label.defined && self.label_tag == 'legend' %] [% INCLUDE $self.label_filename %][% END %][% IF self.errors %][% FOREACH error = self.errors %] [% error.message %][% END %][% END %][% IF self.label.defined && self.label_tag != 'legend' %] [% INCLUDE $self.label_filename %][% END %][% IF self.container_tag.defined %] [% END %][% content %][% IF self.comment.defined %] [% self.comment %] [% END %][% IF self.container_tag.defined %] [% END %][% IF self.javascript.defined %] [% END %]multi100644001751001752 71612331714662 21300 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/root/formfu[% WRAPPER field %] [% FOREACH element = self.elements %][% IF element.reverse_multi %][% INCLUDE $element.field_filename self = element %][% IF element.label.defined %] [% INCLUDE $element.label_filename self = element %][% END %][% ELSE %][% IF element.label.defined %][% INCLUDE $element.label_filename self = element %] [% END %][% INCLUDE $element.field_filename self = element %][% END %] [% END %][% END %]label100644001751001752 14712331714662 21223 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/root/formfu<[% self.label_tag %][% process_attrs(self.label_attributes) %]>[% self.label %]block100644001751001752 32112331714662 21230 0ustar00carlcarl000000000000HTML-FormFu-2.01/examples/unicode/root/formfu[% INCLUDE start_block %] [% IF self.content.defined %][% self.content %] [% ELSE %][% FOREACH element = self.elements %][% INCLUDE $element.filename self = element %] [% END %][% END %][% INCLUDE end_block %]recaptcha100644001751001752 14712331714662 21234 0ustar00carlcarl000000000000HTML-FormFu-2.01/share/templates/tt/xhtml[% WRAPPER field %] [% self.recaptcha_html %][% END %]non_block100644001751001752 6612331714662 21226 0ustar00carlcarl000000000000HTML-FormFu-2.01/share/templates/tt/xhtml<[% self.tag %][% process_attrs(self.attributes) %] />end_block100644001751001752 6312331714662 21177 0ustar00carlcarl000000000000HTML-FormFu-2.01/share/templates/tt/xhtml[% IF self.tag.defined %][% END %]multiple_text_fields.t100644001751001752 75312331714662 21300 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregateuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo'); $form->element('Text')->name('foo'); $form->process( { foo => [qw/ a b /], } ); my $xhtml = <
EOF is( "$form", $xhtml ); integer.t100644001751001752 132512331714662 21216 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/force_errorsuse strict; use warnings; use Test::More tests => 6; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Integer')->force_errors(1); $form->element('Text')->name('bar')->constraint('Integer')->force_errors(1); { $form->process( { foo => '12', bar => "12\n", } ); ok( !$form->has_errors('foo') ); ok( $form->has_errors('bar') ); ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } ); } { $form->process( { foo => 0, bar => "0\n", } ); ok( !$form->has_errors('foo') ); ok( $form->has_errors('bar') ); ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } ); } required.t100644001751001752 253012331714662 21255 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 16; use HTML::FormFu; use lib 't/lib'; use HTMLFormFu::TestLib; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('Required'); # Valid { $form->process( { foo => 'yada', bar => 'nada', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } # Missing - Invalid { $form->process( { foo => 'yada', } ); ok( $form->valid('foo'), 'foo value' ); ok( !$form->valid('bar'), 'bar not valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( !grep { $_ eq 'bar' } $form->valid ); } # Empty string - Invalid { $form->process( { foo => '', bar => 2, } ); ok( !$form->valid('foo'), 'foo not valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( !grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } # "0" is valid { $form->process( { foo => 0, bar => 2, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'foo valid' ); ok( grep { $_ eq 'foo' } $form->valid ); ok( grep { $_ eq 'bar' } $form->valid ); } minrange.t100644001751001752 115112331714662 21233 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('MinRange')->min(3); $form->element('Text')->name('bar')->constraint('MinRange')->min(3); # Valid { $form->process( { foo => 3, bar => 4, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 1, bar => 6, } ); ok( !$form->valid('foo'), 'foo not valid' ); ok( $form->valid('bar'), 'bar not valid' ); } callback.t100644001751001752 135712331714662 21177 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; # base the package name on the test file path # to stop 'redefined' warnings under Test::Aggregate::Nested package My::Constraints::Callback; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Callback')->callback( \&cb ); $form->element('Text')->name('bar')->constraint('Callback')->callback("My::Constraints::Callback::cb"); sub cb { my $value = shift; ::ok(1) if grep { $value eq $_ ? 1 : 0 } qw/ 1 0 a /; return 1; } package main; use Test::More tests => 5; # Valid { $form->process( { foo => 1, bar => [ 0, 'a', 'b' ], } ); ::ok( $form->valid('foo'), 'foo valid' ); ::ok( $form->valid('bar'), 'bar valid' ); } not_word.t100644001751001752 113012331714662 21263 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('Not_Word'); # Valid { $form->process( { foo => ' ', bar => "\t", } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'a', bar => "\n", } ); ok( $form->has_errors('foo'), 'foo has_errors' ); ok( $form->valid('bar'), 'bar valid' ); } localize.t100644001751001752 105112331714662 21234 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo'); $form->constraint('Required'); $form->constraint('MinLength')->min(3); $form->constraint('Regex')->regex(qr/^\d+$/) ->message_loc('form_constraint_integer'); $form->process( { foo => 'a' } ); like( $form->get_field('foo'), qr/This field must be an integer/ ); like( $form->get_field('foo'), qr/Must be at least 3 characters long/ ); dependon.t100644001751001752 117512331714662 21235 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('DependOn') ->others( [qw/ bar baz /] ); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); # Valid { $form->process( { foo => 1, bar => 'a', baz => [2], } ); ok( !$form->has_errors ); } # Invalid { $form->process( { foo => 1, bar => '', baz => 2, } ); ok( $form->valid('foo') ); ok( $form->has_errors('bar') ); ok( $form->valid('baz') ); } maxrange.t100644001751001752 115112331714662 21235 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('MaxRange')->max(5); $form->element('Text')->name('bar')->constraint('MaxRange')->max(5); # Valid { $form->process( { foo => 3, bar => 4, } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 1, bar => 6, } ); ok( $form->valid('foo'), 'foo not valid' ); ok( !$form->valid('bar'), 'bar not valid' ); } submit_no_value.t100644001751001752 143212331714662 21221 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo')->constraint('Required'); $form->element('Text')->name('bar'); $form->element('Submit')->name('submit'); { my $xhtml = qq{
}; is( $form->get_field( { type => 'Submit' } ), $xhtml ); } =pod After an error, check that submit doesn't contain C<< value="" >>, because the browser won't display the default text label, "submit Query" or whatever. =cut { $form->process( { bar => 1 } ); my $xhtml = qq{
}; is( $form->get_field( { type => 'Submit' } ), $xhtml ); } filter_run_once.t100644001751001752 43612331714662 21166 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $count = 0; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->filter( Callback => 'foo' )->callback( sub { $count++ } ); $form->process( { foo => 'whatever', } ); is( $count, 1 ); pre_1_00_compat.t100644001751001752 207512331714662 20702 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; # # The HTML below should never be changed # If necessary, the form config should be changed to show # how to achieve legacy HTML generation # my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/bugs/pre_1_00_compat.yml'); is( "$form", <
The Foo
HTML $form->process( { foo => '', } ); is( "$form", <
This field is required The Foo
HTML filters000755001751001752 012331714662 17473 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nestedregex.t100644001751001752 103412331714662 21130 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nested/filtersuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new; $form->auto_fieldset( { nested_name => 'foo' } ); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); $form->filters( { type => 'Regex', names => [qw/ foo.bar foo.baz /], match => 'a', replace => 'A', } ); $form->process( { 'foo.bar' => 'abc', 'foo.baz' => 'def', } ); is( $form->param('foo.bar'), 'Abc' ); is( $form->param('foo.baz'), 'def' ); elements000755001751001752 012331714662 17637 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nesteddate.t100644001751001752 3260412331714662 21126 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nested/elementsuse strict; use warnings; use Test::More tests => 11; use HTML::FormFu; use DateTime; my $dt = DateTime->new( day => 6, month => 8, year => 2007 ); my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->auto_fieldset( { nested_name => 'date' } ); $form->element('Date')->name('foo')->strftime("%m/%d/%Y") ->day( { prefix => '-- Day --', } )->month( { prefix => '-- Month --', short_names => 1, } )->year( { prefix => '-- Year --', list => [ 2007 .. 2017 ], } )->default($dt)->auto_inflate(1)->constraint('Required'); $form->element('Date')->name('bar')->default('14-08-2007') ->year( { list => [ 2007 .. 2017 ] } ); $form->process; is( "$form", <
HTML $form->process( { 'date.foo_day', 30, 'date.foo_month', 6, 'date.foo_year', 2007, 'date.bar_day', 1, 'date.bar_month', 7, 'date.bar_year', 2007, } ); ok( $form->submitted_and_valid ); my $foo = $form->param('date.foo'); my $bar = $form->param('date.bar'); isa_ok( $foo, 'DateTime' ); ok( !ref $bar ); is( $foo, "06/30/2007" ); is( $bar, "01-07-2007" ); my $foo_field = $form->get_field('foo'); my $bar_field = $form->get_field('bar'); is( "$form", <
HTML # incorrect date $form->process( { 'date.foo_day', 29, 'date.foo_month', 2, 'date.foo_year', 2007, } ); ok( $form->submitted ); ok( $form->has_errors ); ok( !defined $form->param('date.foo') ); is( "$form", <
Invalid date
HTML_ERRORS text.t100644001751001752 121012331714662 21142 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nested/elementsuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->auto_fieldset( { nested_name => 'text' } ); my $element = $form->element('Text')->name('foo'); is( "$form", <
EOF $form->process( { "text.foo" => 42, } ); is( $form->param('text.foo'), 42 ); is( "$form", <
EOF stashvalid.yml100644001751001752 13212331714662 21223 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/plugins--- elements: - name: foo - name: bar plugins: - type: StashValid name: foo validator.t100644001751001752 146112331714662 21225 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/validatorsuse strict; use warnings; use Test::More tests => 6; use lib 't/lib'; use HTML::FormFu; my $form = HTML::FormFu->new->localize_class('HTMLFormFu::I18N'); $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->validator('+HTMLFormFu::MyValidator'); # Valid { $form->process( { foo => 'aaa', bar => 'bbbbbbb', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'aaa', bar => 'foo', } ); ok( $form->valid('foo'), 'foo valid' ); ok( !$form->valid('bar'), 'bar not valid' ); my ($error) = @{ $form->get_errors }; is( $error->type, 'HTMLFormFu::MyValidator' ); is( $error->message, 'myvalidator error!' ); } htmlscrubber.t100644001751001752 231712331714662 21235 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 6; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->filter('HTMLScrubber'); $form->element('Text')->name('bar')->filter('HTMLScrubber')->allow( ['b'] ); $form->element('Text')->name('fum')->filter('HTMLScrubber') ->rules( [ '*' => 0, p => { '*' => 0 }, a => { href => 1, '*' => 0 } ] ); my $original_foo = "

message

"; my $filtered_foo = "message"; my $original_bar = "

message

"; my $filtered_bar = "message"; my $original_fum = "

messagetext

"; my $filtered_fum = "

messagetext

"; $form->process( { foo => $original_foo, bar => $original_bar, fum => $original_fum, } ); # foo is quoted is( $form->param('foo'), $filtered_foo, 'foo filtered' ); is( $form->params->{foo}, $filtered_foo, 'foo filtered' ); # bar is filtered is( $form->param('bar'), $filtered_bar, 'bar filtered' ); is( $form->params->{bar}, $filtered_bar, 'bar filtered' ); # fum is filtered is( $form->param('fum'), $filtered_fum, 'fum filtered' ); is( $form->params->{fum}, $filtered_fum, 'fum filtered' ); compoundjoin.t100644001751001752 105412331714662 21242 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/filters/compoundjoin.yml'); $form->process; $form->process( { 'rep_1.address.number' => '10', 'rep_1.address.street' => 'Downing Street', } ); ok( $form->submitted_and_valid ); is( $form->param_value('rep_1.address'), '10 Downing Street' ); is_deeply( $form->params, { rep_1 => { address => '10 Downing Street' }, }, ); formatnumber.t100644001751001752 206312331714662 21240 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filtersuse strict; use warnings; our $count; BEGIN { $count = 3 } use Test::More tests => $count; use HTML::FormFu; use Number::Format; use POSIX qw( setlocale LC_NUMERIC ); my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/filters/formatnumber.yml'); my $backup_locale = setlocale(LC_NUMERIC); SKIP: { # first test the de_DE locale is available my $ok = setlocale( LC_NUMERIC, 'de_DE' ); if ( !$ok ) { # not available - restore locale and bail setlocale( LC_NUMERIC, $backup_locale ); skip 'de_DE locale not available', $count; } my $format = Number::Format->new; my $formatted_number = $format->format_number('23000222.22'); isnt( $formatted_number, '23000222.22', 'format of number has changed' ); # restore orginal locale setlocale( LC_NUMERIC, $backup_locale ); { $form->process( { foo => $formatted_number, } ); ok( $form->submitted_and_valid ); is( $form->param_value('foo'), '23000222.22', 'number no longer in german formatting' ); } } regex_eval.yml100644001751001752 22312331714662 21172 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/filters--- elements: - name: foo filters: - type: Regex match: '\A.*?([0-9]+(?:\.[0-9]+)?).*\z' replace: '$1' eval: 1 file_post.txt100644001751001752 710412331714662 21244 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elements--xYzZY Content-Disposition: form-data; name="foo.bar" foo --xYzZY Content-Disposition: form-data; name="foo.bar"; filename="one.txt" Content-Length: 4 Content-Type: text/plain One --xYzZY Content-Disposition: form-data; name="multiple" foo --xYzZY Content-Disposition: form-data; name="multiple"; filename="one.txt" Content-Length: 4 Content-Type: text/plain One --xYzZY Content-Disposition: form-data; name="multiple"; filename="two.txt" Content-Length: 5 Content-Type: text/plain Two! --xYzZY Content-Disposition: form-data; name="hello_world"; filename="hello_world.txt" Content-Length: 13 Content-Type: text/plain Hello World! --xYzZY Content-Disposition: form-data; name="does_not_exist_gif"; filename="does_not_exist.gif" Content-Type: application/octet-stream --xYzZY Content-Disposition: form-data; name="100x100_gif"; filename="100x100.gif" Content-Length: 896 Content-Type: image/gif GIF89add@@@000pppPPP ```!,dd#dihlBp,tmxP_1l2ΨZ*v+rI/xL|G1z}SY3|ns;:'`\XV]rx{~F4<p514;<10417a;  3 5 M41 5 ǀMsmG -&0_gj°݆T) 0#V/PeA0p{0 *&F>CuS@C U]= ~vDa\"zV#BT!"j1$c1u} @\i,X$h5pK IN5'"X-  f PBfV֋ʀ#_,+ze5 XN 4@55%Whܠøș0.M,d#(@YYeԘ r*$ՊQzW*JEкZ; ۇzF+!; --xYzZY Content-Disposition: form-data; name="300x300_gif"; filename="300x300.gif" Content-Length: 1656 Content-Type: image/gif GIF89a,,@@@000pppPPP ߏ```!,,,#dihlp,tm|pH,Ȥrl:Ч(JZجv5NxL.zn|N~~iTA|nbVJ@¦Ɲʔ΍҆xqjg:X} oALP ÆB'qan#Gu? )RɒNԦr.l&Me6o˩SϞ~%t(F!Mk)S`H.*!ժbuŮ^5 q,YfώL$۶)e)w˺ve[s/_~ ,'A#&xQh!s*ZP12gl? -ZyNzҮ3v_f&{w$ݾa㿆#|9 5:A֯ʮ]. LΣ}=ۨ>}M/|?q2_? H`Cz(1%18< A7 DPȃ;0@ bsA=@> $`@|uQ *0#ZB@@ c;Z9O=B<@ ! #4X(YOc* %jS@'d=\ <YAPv 3ZʟzahB"k#K,:`j.ҚdaH0fКlZ#l(  fV I`<,fh&m `'=4@j;nLjDۙ—8@CrR^˃ 90,x"B(I";c[@Lu6Ptx{wwkuSWHnur3x<P8|rws5l^: ,:=Pɣ h <,&{oJo |:*& s 0@3{ y ޢj-c ,ݯ 7Mq@46M]3T5,MEt3L13ʔP2'L Ŵ1/,L 3ÿԐ/7Kù.?lK2ij,G KDVRx"DT*WJEIqKbRh2Ōx"ƞQ'oI5a1K>ď!")B~ĐAdFٿ: H$G a $+iI\p2$("QAT9=SƕXI>YzUlyK^?_r$>):cҁC#Y)gǚ栤)Hjv)pQ@gYYvA܉zӞfg~Ӝ`ԧ ĠE(srІ:D'J; --xYzZY-- text_errors.t100644001751001752 116112331714662 21261 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 2; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); my $foo = $form->element('Text')->name('foo')->label('My Foo'); my $bar = $form->element('Text')->name('bar'); $form->constraint( Number => 'foo' ); $form->constraint( Word => 'bar' ); $form->constraint( Required => 'foo', 'bar' ); my $foo_xhtml = qq{
}; is( "$foo", $foo_xhtml ); my $bar_xhtml = qq{
}; is( "$bar", $bar_xhtml ); text_layout.t100644001751001752 373412331714662 21272 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/elements/text_layout.yml'); ### is( $form, <
The foo
HTML my $foo = $form->get_field({ name => 'foo' }); ### $foo->layout( { label => [ 'field', 'label_text', ], } ); is( $form, <
HTML ### $foo->layout( [ 'label', { div => { attributes => { class => 'xxx' }, content => 'field' }, }, ] ); is( $form, <
HTML ### $foo->layout( { div => { attributes => { class => 'xxx', }, content => { div => { attributes => { class => 'yyy', }, content => { label => [ 'field', 'label_text', ], }, }, }, }, } ); is( $form, <
HTML date_rename.t100644001751001752 51212331714662 21124 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); my $date = $form->element('Date')->name('foo'); $form->process; # change name $date->name('bar'); $form->process; like( "$form", qr/name="bar_day"/ ); model000755001751001752 012331714662 15641 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregatehashref_create.t100644001751001752 1527612331714662 21164 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/modeluse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Checkbox')->name('bar')->value('y'); $form->auto_fieldset(1); $form->default_model('HashRef'); $form->populate( { elements => [ { type => "DateTime", name => "datetime", auto_inflate => 1, year => { list => [1999] } }, { name => "inflator", deflator => { type => 'Strftime', strftime => '%F %H:%M' }, inflator => { type => "DateTime", parser => { strptime => '%F' } } }, { type => "Repeatable", nested_name => "many", elements => [ { name => "id" }, { type => "Block", name => "nested", elements => [ { type => "Text", name => "foo" } ] } ] }, { type => "Select", name => "single-select", options => [ [qw(1 foo)], [qw(2 bar)] ] }, { type => "Select", name => "multi-select", options => [ [qw(1 foo)], [qw(2 bar)] ] }, { type => "Block", nested_name => "nested", elements => [ { type => "Text", name => "foo" } ] }, { type => "Multi", name => "address", elements => [ { name => "street" }, { name => "number" } ] }, { type => "Multi", name => "address-split", elements => [ { name => "street" }, { name => "number" } ], deflators => [ { type => "CompoundSplit" } ] }, { type => "SimpleTable", rows => [ [ { name => "table1" } ] ] } ] } ); $form->auto_fieldset(0); $form->model->default_values( { datetime => '30-08-1999 22:00', bar => 'y', many => [ { id => 1, foo => "bar" }, { id => 2, foo => "baz" } ], 'single-select' => 1, 'inflator' => '2008-09-22', 'multi-select' => [ 1, 2 ], nested => { foo => "bar" }, address => { street => "Lombardstreet", number => 22 }, 'address-split' => "Lombardstreet 22", table1 => "test" } ); $form->process; is_deeply( $form->model->create, { bar => 'y', many => [ { id => 1, foo => "bar" }, { id => 2, foo => "baz" } ], 'single-select' => 1, 'datetime_year' => 1999, 'datetime_minute' => '00', 'datetime_month' => 8, 'datetime_day' => 30, 'datetime_hour' => '22', 'datetime' => '30-08-1999 22:00', 'multi-select' => [ 1, 2 ], nested => { foo => "bar" }, address => { street => "Lombardstreet", number => 22 }, 'address-split' => { street => "Lombardstreet", number => 22 }, table1 => "test", inflator => '2008-09-22 00:00' } ); $form->model->options(1); is_deeply( $form->model->create, { bar => 'y', many => [ { id => 1, foo => "bar" }, { id => 2, foo => "baz" } ], 'single-select' => { value => 1, label => "foo" }, 'multi-select' => [ { value => 1, label => "foo" }, { value => 2, label => "bar" } ], nested => { foo => "bar" }, address => { street => "Lombardstreet", number => 22 }, 'address-split' => { street => "Lombardstreet", number => 22 }, table1 => "test", 'datetime_day' => { 'value' => 30, 'label' => 30 }, 'datetime' => '30-08-1999 22:00', 'datetime_minute' => { 'value' => '00', 'label' => '00' }, 'datetime_month' => { 'value' => 8, 'label' => 'August' }, 'datetime_hour' => { 'value' => '22', 'label' => '22' }, 'datetime_year' => { 'value' => '1999', 'label' => '1999' }, inflator => '2008-09-22 00:00' } ); $form->model->flatten(1); $form->model->inflators(1); is_deeply( $form->model->create, { 'datetime_month.label' => 'August', 'multi-select_0.label' => 'foo', 'datetime_hour.value' => '22', 'datetime_minute.value' => '00', 'multi-select_0.value' => '1', 'address-split.street' => 'Lombardstreet', 'datetime' => '30-08-1999 22:00', 'table1' => 'test', 'many_2.foo' => 'baz', 'bar' => 'y', 'datetime_hour.label' => '22', 'address-split.number' => '22', 'many_1.foo' => 'bar', 'many_2.id' => 2, 'datetime_year.label' => 1999, 'single-select.label' => 'foo', 'address.number' => 22, 'address.street' => 'Lombardstreet', 'inflator' => '2008-09-22 00:00', 'datetime_day.value' => 30, 'datetime_minute.label' => '00', 'single-select.value' => '1', 'datetime_month.value' => 8, 'datetime_year.value' => 1999, 'datetime_day.label' => 30, 'nested.foo' => 'bar', 'multi-select_1.label' => 'bar', 'many_1.id' => 1, 'multi-select_1.value' => '2' } ); $form->model->flatten(0); $form->model->default_values( { many => [ { id => undef } ], bar => 'zzz', } ); is_deeply( $form->model->create, { 'inflator' => undef, 'single-select' => { value => undef, label => undef }, 'datetime_hour' => { value => undef, label => undef }, 'address-split' => { 'number' => undef, 'street' => undef }, 'many' => [ { id => undef, foo => undef } ], 'datetime_day' => { value => undef, label => undef }, 'nested' => { 'foo' => undef }, 'datetime' => undef, 'datetime_year' => { value => undef, label => undef }, 'table1' => undef, 'bar' => 'zzz', 'datetime_minute' => { value => undef, label => undef }, 'address' => { 'number' => undef, 'street' => undef }, 'multi-select' => { value => undef, label => undef }, 'datetime_month' => { value => undef, label => undef } } ); get_constraints.t100644001751001752 235512331714662 21244 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 17; use HTML::FormFu; my $form = HTML::FormFu->new; my $fs = $form->element('Fieldset'); $fs->element('Text')->name('name')->constraint('Word'); $fs->element('Text')->name('age')->constraint('Number'); $form->constraint( Required => 'name', 'age' ); { my $constraints = $form->get_constraints; is( @$constraints, 4 ); is( $constraints->[0]->name, 'name' ); is( $constraints->[1]->name, 'name' ); is( $constraints->[2]->name, 'age' ); is( $constraints->[3]->name, 'age' ); is( $constraints->[0]->type, 'Word' ); is( $constraints->[1]->type, 'Required' ); is( $constraints->[2]->type, 'Number' ); is( $constraints->[3]->type, 'Required' ); } { my $constraints = $form->get_constraints('name'); is( @$constraints, 2 ); is( $constraints->[0]->type, 'Word' ); is( $constraints->[1]->type, 'Required' ); } { my $constraints = $form->get_constraints( { name => 'age' } ); is( @$constraints, 2 ); is( $constraints->[0]->type, 'Number' ); is( $constraints->[1]->type, 'Required' ); } { my $constraints = $form->get_constraints( { type => 'Number' } ); is( @$constraints, 1 ); is( $constraints->[0]->name, 'age' ); } config_callback.t100644001751001752 54212331714662 21073 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new; $form->config_callback( { plain_value => sub { return if !defined $_; s/Foo/Bar/; } } ); $form->load_config_file('t-aggregate/form/config_callback.yml'); is( $form->get_field('foo')->label, 'Bar' ); OutputProcessor.pm100644001751001752 172012331714662 20760 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFupackage HTML::FormFu::OutputProcessor; $HTML::FormFu::OutputProcessor::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; with 'HTML::FormFu::Role::HasParent', 'HTML::FormFu::Role::Populate'; use HTML::FormFu::ObjectUtil qw( form parent ); use Scalar::Util qw( reftype ); use Carp qw( croak ); has type => ( is => 'rw', traits => ['FormFuChained'] ); sub clone { my ($self) = @_; my %new = %$self; return bless \%new, ref $self; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::OutputProcessor - Post-process HTML output =head1 DESCRIPTION Post-process a form or element's HTML. =head1 CORE OUTPUT PROCESSORS =over =item L =item L =back =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut File.pm100644001751001752 273312331714662 20570 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Constraintpackage HTML::FormFu::Constraint::File; $HTML::FormFu::Constraint::File::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Constraint'; use Scalar::Util qw( blessed ); sub constrain_value { my ( $self, $value ) = @_; return 1 if !defined $value || $value eq ''; return blessed($value) && $value->isa('HTML::FormFu::Upload'); } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Constraint::File - File Upload Constraint =head1 DESCRIPTION Ensure the submitted value is a file upload. This Constraint is not needed if you use any of the C Constraints, as they all make the same check as this Constraint does. =head1 LIMITATIONS This can only verify that your CGI backend (CGI, Catalyst, CGI::Simple) thinks it was a file upload. If the user submits a filename which doesn't exist on their system, you will probably get a valid L object, with a valid filehandle, but no Content-Length. This Constraint would still see this as a valid uploaded file - if you want to ensure that you get a file with content, instead use L with L set to C<1>. =head1 SEE ALSO Is a sub-class of, and inherits methods from L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Word.pm100644001751001752 140012331714662 20612 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Constraintpackage HTML::FormFu::Constraint::Word; $HTML::FormFu::Constraint::Word::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Constraint::Regex'; sub regex { return qr/^\w*\z/; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Constraint::Word - Single Word Constraint =head1 DESCRIPTION Ensure the input is a single word. Which characters are considered "word characters" will depend on the current locale. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L L =head1 AUTHOR Carl Franks C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Bool.pm100644001751001752 124212331714662 20576 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Constraintpackage HTML::FormFu::Constraint::Bool; $HTML::FormFu::Constraint::Bool::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Constraint::Regex'; sub regex { return qr/^[01]?\z/; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Constraint::Bool - Boolean Constraint =head1 DESCRIPTION Value must be either 1 or 0. =head1 SEE ALSO Is a sub-class of, and inherits methods from L, L L =head1 AUTHOR Carl Franks C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Manual000755001751001752 012331714662 16277 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuUnicode.pod100644001751001752 1316212331714662 20554 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Manual=head1 NAME HTML::FormFu::Manual::Unicode - Working with unicode =head1 DESCRIPTION Working with unicode. For a practical example, see the Catalyst application in the C directory in this distribution. =head1 ASSUMPTIONS In this tutorial, we're assuming that all encodings are UTF-8. It's relatively simple to combine different encodings from different sources, but that's beyond the scope of this tutorial. For simplicity, we're also going to assume that you're using L for your web-framework, L for your database ORM, L for your templating system, and YAML format C configuration files, with L installed. However, the principles we'll cover should translate to whatever technologies you chose to work with. =head1 BASICS To make it short and sweet: you must decode all data going into your program, and encode all data coming from your program. Skip to L if you want to see what you need to do without any other explanation. =head1 INPUT =head2 Input parameters from the browser If you're using C, L will decode all input parameters sent from the browser to your application - see L. If you're using some other framework or, in any case, you need to decode the input parameters yourself, please take a look at L. =head2 Data from the database If you're using L, L is likely the best options, as it will decode all input retrieved from the database - see L. In other cases (i.e. plain DBI), you still need to decode the string data coming from the database. This varies depending on the database server. For MySQL, for instance, you can use the C attribute: see L documentation for details. =head2 Your template files Set TT to decode all template files - see L. =head2 HTML::FormFu's own template files Set C to decode all template files - see L. =head2 HTML::FormFu form configuration files If you're using C config files, your files will automatically be decoded by C and C. If you have L config files, your files will automatically be decoded by C and C, which automatically sets L C<-UTF8> setting. =head2 Your perl source code Any perl source files which contain Unicode characters must use the L module. =head1 OUTPUT =head2 Data saved to the database With C, L will encode all data sent to the database - see L. =head2 HTML sent to the browser With C, L will encode all output sent from your application to the browser - see L. In other circumstances you need to be sure to output your Unicode (decoded) strings in UTF-8. To do this you can encode your output before it's sent to the browser with something like: use utf8; if ( $output && utf8::is_utf8($output) ){ utf8::encode( $output ); # Encodes in-place } Another option is to set the C for C: bindmode STDOUT, ':utf8'; However, be sure to do this B when sending UTF-8 data: if you're serving images, PFD files, etc, C should remain set to C<:raw>. =head1 CHANGES REQUIRED =head2 Catalyst Configuration Add L to the list of Catalyst plugins: use Catalyst qw( ConfigLoader Static::Simple Unicode ); =head2 DBIx::Class Configuration Add L to the list of components loaded, for each table that has columns storing unicode: __PACKAGE__->load_components( qw( UTF8Columns HTML::FormFu PK::Auto Core ) ); Pass each column name that will store unicode to C: __PACKAGE__->utf8_columns( qw( lastname firstname ) ); =head2 TT Configuration Tell TT to decode all template files, by adding the following to your application config in MyApp.pm package MyApp; use strict; use parent 'Catalyst'; use Catalyst qw( ConfigLoader ); MyApp->config({ 'View::TT' => { ENCODING => 'UTF-8', }, }); 1; =head2 HTML::FormFu Template Configuration Make C tell TT to decode all template files, by adding the following to your C Catalyst configuration file: package MyApp; use strict; use parent 'Catalyst'; use Catalyst qw( ConfigLoader ); MyApp->config({ 'Controller::HTML::FormFu' => { constructor => { tt_args => { ENCODING => 'UTF-8', }, }, }, }); 1; These above 2 examples should be combined, like so: package MyApp; use strict; use parent 'Catalyst'; use Catalyst qw( ConfigLoader ); MyApp->config({ 'Controller::HTML::FormFu' => { constructor => { tt_args => { ENCODING => 'UTF-8', }, }, }, 'View::TT' => { ENCODING => 'UTF-8', }, }); 1; =head1 AUTHORS Carl Franks C Michele Beltrame C (contributions) =head1 COPYRIGHT This document is free, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Callback.pm100644001751001752 252312331714662 20503 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Filterpackage HTML::FormFu::Filter::Callback; $HTML::FormFu::Filter::Callback::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Filter'; has callback => ( is => 'rw', traits => ['FormFuChained'] ); sub filter { my ( $self, $value, $params ) = @_; my $callback = $self->callback || sub {$value}; no strict 'refs'; return $callback->( $value, $params ); } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Filter::Callback - filter with custom subroutine =head1 SYNOPSIS $field->filter({ type => 'Callback', callback => \&my_filter, }); --- elements: - type: Text name: foo filters: - type: Callback callback: "main::my_filter" sub my_filter { my ($value) = @_; # do something to $value return $value; } =head1 DESCRIPTION Filter using a user-provided subroutine. =head1 METHODS =head2 callback Arguments: \&code-reference Arguments: "subroutine-name" =head1 AUTHOR Carl Franks, C Based on the original source code of L, by Lyo Kato, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut Exception000755001751001752 012331714662 17020 5ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFuInput.pm100644001751001752 531412331714662 20620 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Exceptionpackage HTML::FormFu::Exception::Input; $HTML::FormFu::Exception::Input::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Exception'; use HTML::FormFu::Attribute qw( mk_attrs ); use HTML::FormFu::Util qw( append_xml_attribute literal xml_escape ); has processor => ( is => 'rw', traits => ['FormFuChained'] ); has forced => ( is => 'rw', traits => ['FormFuChained'] ); __PACKAGE__->mk_attrs(qw( attributes )); sub BUILD { my ( $self, $args ) = @_; $self->attributes({}); return; } sub name { my ($self) = @_; return $self->parent->name; } sub message { my ( $self, $message ) = @_; if ( @_ > 1 ) { return $self->{message} = $message; } return $self->{message} if defined $self->{message}; return $self->processor->message if defined $self->processor->message; my %string = ( f => defined $self->form->id ? $self->form->id : '', n => defined $self->name ? $self->name : '', t => defined $self->type ? lc( $self->type ) : '', s => $self->stage, ); $string{t} =~ s/::/_/g; $string{t} =~ s/\+//; my $error_message = $self->parent->auto_error_message; $error_message =~ s/%([fnts])/$string{$1}/g; $error_message = $self->form->localize( $error_message, $self->processor->localize_args ); return $self->{message} = $error_message; } sub type { my ($self) = @_; return $self->processor->type; } sub clone { my ($self) = @_; my %new = %$self; return bless \%new, ref $self; } around render_data_non_recursive => sub { my ( $orig, $self, $args ) = @_; my $render = $self->$orig( { processor => $self->processor, forced => $self->forced, name => $self->name, message => $self->message, type => $self->type, $args ? %$args : (), }); $self->_render_attributes($render); return $render; }; sub _render_attributes { my ( $self, $render ) = @_; my $attrs = xml_escape( $self->attributes ); my $auto_error_class = $self->parent->auto_error_class; if ( defined $auto_error_class ) { my %string = ( f => defined $self->form->id ? $self->form->id : '', n => defined $self->name ? $self->name : '', t => defined $self->type ? lc( $self->type ) : '', s => $self->stage, ); $string{t} =~ s/::/_/g; $string{t} =~ s/\+//; $auto_error_class =~ s/%([fnts])/$string{$1}/g; append_xml_attribute( $attrs, 'class', $auto_error_class ); } $render->{attributes} = $attrs; } __PACKAGE__->meta->make_immutable; 1; repeatable100644001751001752 17412331714662 21406 0ustar00carlcarl000000000000HTML-FormFu-2.01/share/templates/tt/xhtml[% FOREACH element = self.elements %][% INCLUDE $element.filename self = element %][% UNLESS loop.last %] [% END %][% END %]start_form100644001751001752 66512331714662 21467 0ustar00carlcarl000000000000HTML-FormFu-2.01/share/templates/tt/xhtml[% IF self.form_error_message.defined %]
[% self.form_error_message %]
[% END %][% IF self.javascript_src.defined %][% FOREACH src = self.javascript_src.list %] [% END %][% END %][% IF self.javascript.defined %] [% END %]dependon.t100644001751001752 222112331714662 21351 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/force_errorsuse strict; use warnings; use Test::More tests => 13; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('DependOn') ->others( [qw/ bar baz /] )->force_errors(1); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); # valid { $form->process( { foo => 1, bar => 'a', baz => [2], } ); ok( $form->submitted_and_valid ); ok( !$form->has_errors('foo') ); ok( !$form->has_errors('bar') ); ok( !$form->has_errors('baz') ); ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } ); } # invalid { $form->process( { foo => 1, bar => '', baz => 2, } ); ok( !$form->submitted_and_valid ); ok( !$form->has_errors('foo') ); ok( $form->has_errors('bar') ); ok( !$form->has_errors('baz') ); ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } ); ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } ); } equal_not.t100644001751001752 304412331714662 21425 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 15; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Equal') ->others( [ 'bar', 'baz' ] )->not(1); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); # Valid { $form->process( { foo => 'yada', bar => 'boba', baz => 'sith', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( $form->valid('bar'), 'baz valid' ); } # Valid { $form->process( { foo => '', bar => '', baz => '', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( $form->valid('baz'), 'baz valid' ); } # Valid { $form->process( { foo => '', bar => 'yada', baz => 'boba', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( $form->valid('baz'), 'baz valid' ); } # Valid { $form->process( { foo => '', bar => 'yada', baz => '', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); ok( $form->valid('baz'), 'baz valid' ); } # Invalid { $form->process( { foo => 'yada', bar => 'yada', baz => 'x', } ); ok( $form->valid('foo'), 'foo valid' ); ok( !$form->valid('bar'), 'bar not valid' ); ok( $form->valid('baz'), 'baz valid' ); } maxlength.t100644001751001752 133612331714662 21427 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 5; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('MaxLength')->max(5); $form->element('Text')->name('bar')->constraint('MaxLength')->max(5); # Valid { $form->process( { foo => 'abc', bar => 'abcde', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'ab', bar => 'abcdef', } ); ok( $form->valid('foo'), 'foo valid' ); ok( !$form->valid('bar'), 'bar not valid' ); is( $form->get_error('bar')->message, 'Must not be longer than 5 characters long' ); } printable.t100644001751001752 115212331714662 21414 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo'); $form->element('Text')->name('bar'); $form->constraint('Printable'); # Valid { $form->process( { foo => 'aaa', bar => 'bbbbbbb', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'aaa', bar => '日本語', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->has_errors('bar'), 'bar has errors' ); } minlength.t100644001751001752 132612331714662 21424 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 5; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('MinLength')->min(3); $form->element('Text')->name('bar')->constraint('MinLength')->min(3); # Valid { $form->process( { foo => 'abc', bar => 'abcd', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'ab', bar => 'abcdef', } ); ok( !$form->valid('foo'), 'foo not valid' ); ok( $form->valid('bar'), 'bar valid' ); is( $form->get_error('foo')->message, 'Must be at least 3 characters long' ); } allornone.t100644001751001752 157512331714662 21436 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 7; use HTML::FormFu; my $form = HTML::FormFu->new->indicator( sub {1} ); $form->element('Text')->name('foo')->constraint('AllOrNone') ->others( [qw/ bar baz bif /] ); $form->element('Text')->name('bar'); $form->element('Text')->name('baz'); $form->element('Text')->name('bif'); # Valid { $form->process( { foo => 1, bar => 'a', baz => [2], bif => [ 3, 4 ], } ); ok( !$form->has_errors ); } # Valid { $form->process( {} ); ok( !$form->has_errors ); } # Invalid { $form->process( { foo => 1, bar => '', baz => [2], bif => [ 3, 4 ], } ); ok( $form->has_errors ); ok( $form->valid('foo') ); ok( $form->has_errors('bar') ); ok( $form->valid('baz') ); ok( $form->valid('bif') ); } file_size.t100644001751001752 376112331714662 21415 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More; use HTML::FormFu; eval "use CGI"; if ($@) { plan skip_all => 'CGI required'; die $!; } plan tests => 10; # Copied from CGI.pm - http://search.cpan.org/perldoc?CGI %ENV = ( %ENV, 'SCRIPT_NAME' => '/test.cgi', 'SERVER_NAME' => 'perl.org', 'HTTP_CONNECTION' => 'TE, close', 'REQUEST_METHOD' => 'POST', 'SCRIPT_URI' => 'http://www.perl.org/test.cgi', 'SCRIPT_FILENAME' => '/home/usr/test.cgi', 'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ', 'HTTP_TE' => 'deflate,gzip;q=0.3', 'QUERY_STRING' => '', 'REMOTE_PORT' => '1855', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'PATH' => '/usr/local/bin:/usr/bin:/bin', 'REQUEST_URI' => '/test.cgi', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SCRIPT_URL' => '/test.cgi', 'SERVER_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/home/develop', 'HTTP_HOST' => 'www.perl.org' ); my $q; { my $file = 't-aggregate/elements/file_post.txt'; local *STDIN; open STDIN, "<", $file or die "missing test file $file"; binmode STDIN; $q = CGI->new; } my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/constraints/file_size.yml'); $form->process($q); { ok( $form->submitted ); ok( !$form->has_errors('hello_world') ); ok( $form->has_errors('does_not_exist_gif') ); ok( $form->valid('hello_world') ); ok( !$form->valid('does_not_exist_gif') ); } $form->process( { hello_world => 'not a file', } ); { ok( $form->submitted ); ok( $form->has_errors('hello_world') ); ok( !$form->has_errors('does_not_exist_gif') ); ok( !$form->valid('hello_world') ); ok( !$form->valid('does_not_exist_gif') ); } not_equal.t100644001751001752 114512331714662 21425 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->constraint('Not_Equal')->others('bar'); $form->element('Text')->name('bar'); # Valid { $form->process( { foo => 'yada', bar => 'xxxx', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->valid('bar'), 'bar valid' ); } # Invalid { $form->process( { foo => 'yada', bar => 'yada', } ); ok( $form->valid('foo'), 'foo valid' ); ok( $form->has_errors('bar'), 'bar valid' ); } file_mime.t100644001751001752 372512331714662 21372 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/constraintsuse strict; use warnings; use Test::More; use HTML::FormFu; eval "use CGI"; if ($@) { plan skip_all => 'CGI required'; die $!; } plan tests => 10; # Copied from CGI.pm - http://search.cpan.org/perldoc?CGI %ENV = ( %ENV, 'SCRIPT_NAME' => '/test.cgi', 'SERVER_NAME' => 'perl.org', 'HTTP_CONNECTION' => 'TE, close', 'REQUEST_METHOD' => 'POST', 'SCRIPT_URI' => 'http://www.perl.org/test.cgi', 'SCRIPT_FILENAME' => '/home/usr/test.cgi', 'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ', 'HTTP_TE' => 'deflate,gzip;q=0.3', 'QUERY_STRING' => '', 'REMOTE_PORT' => '1855', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'PATH' => '/usr/local/bin:/usr/bin:/bin', 'REQUEST_URI' => '/test.cgi', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SCRIPT_URL' => '/test.cgi', 'SERVER_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/home/develop', 'HTTP_HOST' => 'www.perl.org' ); my $q; { my $file = 't-aggregate/elements/file_post.txt'; local *STDIN; open STDIN, "<", $file or die "missing test file $file"; binmode STDIN; $q = CGI->new; } my $form = HTML::FormFu->new; $form->load_config_file('t-aggregate/constraints/file_mime.yml'); $form->process($q); { ok( $form->submitted ); ok( !$form->has_errors('hello_world') ); ok( !$form->has_errors('100x100_gif') ); ok( $form->valid('hello_world') ); ok( $form->valid('100x100_gif') ); } $form->process( { hello_world => 'not a file', } ); { ok( $form->submitted ); ok( $form->has_errors('hello_world') ); ok( !$form->has_errors('100x100_gif') ); ok( !$form->valid('hello_world') ); ok( !$form->valid('100x100_gif') ); } custom_label.t100644001751001752 256612331714662 21366 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/examplesuse strict; use warnings; use Test::More; eval { require Template; }; if ($@) { plan skip_all => 'Template.pm required'; die $@; } else { plan tests => 1; } use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->auto_fieldset( { legend => 'Foo' } ); $form->element('Text')->name('foo')->label('Foo'); $form->element('Text')->name('bar')->label('Bar'); $form->element('Hidden')->name('baz'); $form->element('Submit')->name('submit'); my $template = Template->new; my $output; $template->process( \*DATA, { form => $form }, \$output ) or die $template->error; my $xhtml = <
Foo : :
EOF is( $output, $xhtml ); __DATA__ [% form.start %] [% form.get_element('type', 'Fieldset').start %] [% form.get_field('foo').render_label %]: [% form.get_field('foo').render_field %] [% form.get_field('bar').render_label %]: [% form.get_field('bar').render_field %] [% form.get_field('baz') %] [% form.get_field('submit') %] [% form.get_element('type', 'Fieldset').end %] [% form.end %] name_regex_chars.t100644001751001752 40212331714662 21274 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new; $form->element('Text')->name('foo/bar'); { $form->process( { 'foo/bar' => 'bam' } ); is( $form->param('foo/bar'), 'bam', 'foo/bar valid' ); } value_no_default.t100644001751001752 524012331714662 21343 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/bugsuse strict; use warnings; use Test::More tests => 20; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->indicator('my_hidden'); $form->element('Button')->name('my_button')->value(1); $form->element('Checkbox')->name('my_checkbox1')->value(1) ->attrs( { checked => 'checked' } ); $form->element('Checkbox')->name('my_checkbox2')->value(0); $form->element('ContentButton')->name('my_contentbutton')->value(1); $form->element('Hidden')->name('my_hidden')->value(1); $form->element('Image')->name('my_image')->value(1); #$form->element('Password')->name('my_password')->value(1)->fill(1); $form->element('Radio')->name('my_radio1')->value(1) ->attrs( { checked => 'checked' } ); $form->element('Radio')->name('my_radio2')->value(0); $form->element('Radiogroup')->name('my_radiogroup')->values( [ 1, 0 ] ) ->attrs( { checked => 'checked' } ); $form->element('Reset')->name('my_reset')->value(1); $form->element('Select')->name('my_select') ->options( [ [ 0 => 'unsubscribed' ], [ 1 => 'subscribed' ] ] ) ->attrs( { selected => 'selected' } ); $form->element('Submit')->name('my_submit')->value(1); $form->element('Text')->name('my_text')->value(1); $form->element('Textarea')->name('my_textarea')->value(1); { like( $form->get_field('my_button'), qr/value="1"/ ); like( $form->get_field('my_checkbox1'), qr/value="1"/ ); like( $form->get_field('my_checkbox2'), qr/value="0"/ ); like( $form->get_field('my_contentbutton'), qr/value="1"/ ); like( $form->get_field('my_hidden'), qr/value="1"/ ); like( $form->get_field('my_image'), qr/value="1"/ ); like( $form->get_field('my_radio1'), qr/value="1"/ ); like( $form->get_field('my_radio2'), qr/value="0"/ ); like( $form->get_field('my_radiogroup'), qr/value="1"/ ); like( $form->get_field('my_reset'), qr/value="1"/ ); like( $form->get_field('my_select'), qr/value="1"/ ); like( $form->get_field('my_submit'), qr/value="1"/ ); like( $form->get_field('my_text'), qr/value="1"/ ); like( $form->get_field('my_textarea'), qr!>1! ); } # make sure XML of the result object has empty values, not defaults { $form->process( { my_hidden => '', } ); like( $form->get_field('my_checkbox1'), qr/value="1"/ ); unlike( $form->get_field('my_checkbox1'), qr/"checked"/ ); like( $form->get_field('my_checkbox2'), qr/value="0"/ ); unlike( $form->get_field('my_checkbox2'), qr/"checked"/ ); like( $form->get_field('my_contentbutton'), qr/value=""/ ); like( $form->get_field('my_hidden'), qr/value=""/ ); } element_name.yml100644001751001752 22312331714662 21314 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nested--- auto_id: '%n' auto_fieldset: nested_name: foo elements: - name: bar - type: Block nested_name: baz elements: - name: 0 multi.t100644001751001752 102212331714662 21311 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nested/elementsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->auto_fieldset( { nested_name => 'nested' } ); my $multi = $form->element('Multi'); $multi->element('Text')->name('foo'); my $form_xhtml = <
EOF is( "$form", $form_xhtml, 'stringified form' ); radio.t100644001751001752 116112331714662 21261 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/nested/elementsuse strict; use warnings; use Test::More tests => 4; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->auto_fieldset( { nested_name => 'radio' } ); $form->element('Radio')->name('foo')->value('foox'); is( "$form", <
EOF { $form->process( { 'radio.foo' => 'foox', } ); ok( $form->valid('radio.foo') ); is( $form->param('radio.foo'), 'foox' ); like( $form->get_field('foo'), qr/checked/ ); } date_default.t100644001751001752 467012331714662 21332 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; use DateTime; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); my $date = $form->element('Date')->name('foo')->strftime("%m/%d/%Y") ->year( { reference => 2007 } ); $form->process; # check that setting default() after calling process() works correctly my $dt = DateTime->new( day => 6, month => 8, year => 2007 ); $date->default($dt); is( "$form", <
HTML date_natural.t100644001751001752 54212331714662 21326 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; use DateTime; { my $today = DateTime->today; my $form = HTML::FormFu->new; my $e = $form->element('Date'); $e->name('foo')->default_natural('today'); $form->process; for (qw( day month year )) { is( $e->$_->{default}, $today->$_ ); } } no_block_tag.t100644001751001752 62312331714662 21304 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/elements/no_block_tag.yml'); my $expected_form_xhtml = <
EOF is( "$form", $expected_form_xhtml ); simple_table.t100644001751001752 127412331714662 21346 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/elements/simple_table.yml'); my $xhtml = <
foo bar
EOF is( "$form", $xhtml ); multi_errors.t100644001751001752 200512331714662 21425 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/elementsuse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new( { elements => [ { type => 'Multi', label => 'My multi', elements => [ { type => 'Text', name => 'foo', }, { type => 'Radio', name => 'bar', } ], }, { type => 'Submit' }, ], constraints => ['Required'], } ); $form->tt_args( { INCLUDE_PATH => 'share/templates/tt/xhtml' } ); $form->indicator( sub {1} ); $form->process( {} ); my $xhtml = <
This field is required This field is required
EOF is( "$form", $xhtml ); transformers000755001751001752 012331714662 17266 5ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregatecallback.t100644001751001752 225312331714662 21351 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/transformersuse strict; use warnings; # base the package name on the test file path # to stop 'redefined' warnings under Test::Aggregate::Nested package My::Transformers::Callback; sub cb { my $value = shift; $value =~ s/a/A/; return $value; } package main; use Test::More tests => 4; use HTML::FormFu; my $can_closure = sub { my ( $value, $params ) = @_; if ( $params->{foo} eq '1' ) { $value .= '_' . $params->{foo}; } $value =~ s/\s*//g; return uc $value; }; my $form = HTML::FormFu->new; $form->element('Text')->name('foo')->transformer('Callback') ->callback( \&My::Transformers::Callback::cb ); $form->element('Text')->name('bar')->transformer('Callback') ->callback("My::Transformers::Callback::cb"); $form->element('Text')->name('coo')->transformer('Callback') ->callback($can_closure); # Valid { $form->process( { foo => 1, bar => [ 0, 'a', 'b' ], coo => 'sTrinG I waNT to CaNonize ', } ); ok( $form->submitted_and_valid ); is( $form->param('foo'), 1 ); is_deeply( [ $form->param('bar') ], [ 0, 'A', 'b' ] ); is( $form->param('coo'), 'STRINGIWANTTOCANONIZE_1' ); } hashref_process.t100644001751001752 150612331714662 21346 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/modeluse strict; use warnings; use Test::More tests => 1; use HTML::FormFu; my $form = HTML::FormFu->new; $form->populate( { elements => [ { type => 'Hidden', name => 'count' }, { type => 'Repeatable', nested_name => 'rep', counter_name => 'count', elements => [ { type => 'Text', name => 'title' }, { type => 'Text', name => 'title2' } ] } ] } ); $form->get_element( { nested_name => 'rep' } )->repeat(2); $form->process( { 'rep_1.title' => 'foo', 'rep_1.title2' => 'bar', 'rep_2.title' => 'foo' } ); is_deeply( $form->model('HashRef')->create, { count => undef, rep => [ { title => 'foo', title2 => 'bar' }, { title => 'foo', title2 => undef } ] } ); default_args_alt.t100644001751001752 145312331714662 21334 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; use Storable qw( dclone ); my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/form/default_args_alt.yml'); # longest match - 'not_in_multi' longer then 'is_input' my $foo = $form->get_field({ name => 'foo' }); like( $foo->attrs->{class}, qr/not_in_multi/ ); # Input within the Multi does not get the 'not_in_multi' class my $bar = $form->get_field({ name => 'bar' }); like( $bar->attrs->{class}, qr/is_input/ ); is ( "$form", <
HTML get_all_elements.t100644001751001752 331712331714662 21340 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 28; use HTML::FormFu; my $form = HTML::FormFu->new; my $fs = $form->element('Fieldset'); my $e1 = $fs->element('Text')->name('foo'); my $e2 = $fs->element('Hidden')->name('foo'); my $e3 = $fs->element('Hidden')->name('bar'); { my $elems = $form->get_all_elements; is( @$elems, 4 ); ok( $elems->[0] == $fs ); ok( $elems->[1] == $e1 ); ok( $elems->[2] == $e2 ); ok( $elems->[3] == $e3 ); } { my $elems = $form->get_all_elements( { type => 'Fieldset' } ); is( @$elems, 1 ); ok( $elems->[0] == $fs ); my $fs_elems = $elems->[0]->get_all_elements; is( @$fs_elems, 3 ); ok( $fs_elems->[0] == $e1 ); ok( $fs_elems->[1] == $e2 ); ok( $fs_elems->[2] == $e3 ); my $e1_elems = $e1->get_all_elements; is( @$e1_elems, 0 ); my $e2_elems = $e2->get_all_elements; is( @$e2_elems, 0 ); my $e3_elems = $e3->get_all_elements; is( @$e3_elems, 0 ); } { my $elems = $form->get_all_elements('foo'); is( @$elems, 2 ); ok( $elems->[0] == $e1 ); ok( $elems->[1] == $e2 ); } { my $elems = $form->get_all_elements( { name => 'foo' } ); is( @$elems, 2 ); ok( $elems->[0] == $e1 ); ok( $elems->[1] == $e2 ); } { my $elems = $form->get_all_elements( { type => 'Hidden' } ); is( @$elems, 2 ); ok( $elems->[0] == $e2 ); ok( $elems->[1] == $e3 ); } { my $elems = $form->get_all_elements( { name => 'foo', type => 'Hidden', } ); is( @$elems, 1 ); ok( $elems->[0] == $e2 ); } { my $elems = $form->get_all_elements( { name => qr/oo/ } ); is( @$elems, 2 ); ok( $elems->[0] == $e1 ); ok( $elems->[1] == $e2 ); } default_args_isa.t100644001751001752 173012331714662 21326 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 7; use HTML::FormFu; use Storable qw( dclone ); my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->load_config_file('t-aggregate/form/default_args_isa.yml'); is( $form->get_element({ type => 'Fieldset' })->attrs->{class}, 'does_block' ); # Multi gets default_args for Block, Field, Multi my $multi = $form->get_all_element({ type => 'Multi' }); is( $multi->attrs->{class}, 'does_block' ); is( $multi->comment, 'Does Field' ); is( $multi->label, 'My Multi' ); # Text gets default_args for Field, Input my $text = $form->get_field({ name => 'bar' }); is( $text->comment, 'Does Field' ); is( $text->id, 'bar' ); is ( "$form", <
Does Field
HTML auto_error_class.t100644001751001752 107212331714662 21377 0ustar00carlcarl000000000000HTML-FormFu-2.01/t-aggregate/formuse strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); $form->element('Text')->name('foo'); $form->element('Text')->name('bar')->auto_error_class('form_%t_%s_error'); $form->constraint('Number'); $form->process( { foo => 'a', bar => 'b', } ); unlike( $form->get_field('foo'), qr/error/ ); like( $form->get_field('foo'), qr/This field must be a number/i ); like( $form->get_field('bar'), qr!\bform_number_constraint_error\b! ); DateTime.pm100644001751001752 2023412331714662 20666 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::DateTime; $HTML::FormFu::Element::DateTime::VERSION = '2.01'; use Moose; use MooseX::Attribute::FormFuChained; extends 'HTML::FormFu::Element::Date'; use Moose::Util qw( apply_all_roles ); use Scalar::Util qw( blessed ); __PACKAGE__->mk_attrs(qw/ hour minute second /); for my $name ( qw( printf_hour printf_minute printf_second ) ) { has $name => ( is => 'rw', default => '%02d', lazy => 1, traits => ['FormFuChained'], ); } after BUILD => sub { my ( $self, $args ) = @_; $self->strftime("%d-%m-%Y %H:%M"); $self->_known_fields( [qw/ day month year hour minute second /] ); $self->field_order( [qw( day month year hour minute )] ); $self->hour( { prefix => [], } ); $self->minute( { prefix => [], } ); $self->second( { prefix => [], } ); $self->printf_hour('%02d'); $self->printf_minute('%02d'); $self->printf_second('%02d'); return; }; sub _add_hour { my ($self) = @_; my $hour = $self->hour; my $hour_name = $self->_build_name('hour'); my @hour_prefix = ref $hour->{prefix} ? @{ $hour->{prefix} } : $hour->{prefix}; if ( exists $hour->{prefix_loc} ) { @hour_prefix = ref $hour->{prefix_loc} ? map { $self->form->localize($_) } @{ $hour->{prefix_loc} } : $self->form->localize( $hour->{prefix_loc} ); } @hour_prefix = map { [ '', $_ ] } @hour_prefix; my $element = $self->element( { type => 'Select', name => $hour_name, options => [ @hour_prefix, map { [ $_, $_ ] } map { sprintf '%02d', $_ } 0 .. 23 ], attributes => $hour->{attributes}, defined $hour->{default} ? ( default => sprintf '%02d', $hour->{default} ) : (), } ); apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); return; } sub _add_minute { my ($self) = @_; my $minute = $self->minute; my $minute_name = $self->_build_name('minute'); my @minute_prefix = ref $minute->{prefix} ? @{ $minute->{prefix} } : $minute->{prefix}; if ( exists $minute->{prefix_loc} ) { @minute_prefix = ref $minute->{prefix_loc} ? map { $self->form->localize($_) } @{ $minute->{prefix_loc} } : $self->form->localize( $minute->{prefix_loc} ); } @minute_prefix = map { [ '', $_ ] } @minute_prefix; my @minutes = $self->_build_number_list( 0, 59, $minute->{interval} ); my $element = $self->element( { type => 'Select', name => $minute_name, options => [ @minute_prefix, map { [ $_, $_ ] } map { sprintf '%02d', $_ } @minutes ], attributes => $minute->{attributes}, defined $minute->{default} ? ( default => sprintf '%02d', $minute->{default} ) : (), } ); apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); return; } sub _add_second { my ($self) = @_; my $second = $self->second; my $second_name = $self->_build_name('second'); my @second_prefix = ref $second->{prefix} ? @{ $second->{prefix} } : $second->{prefix}; if ( exists $second->{prefix_loc} ) { @second_prefix = ref $second->{prefix_loc} ? map { $self->form->localize($_) } @{ $second->{prefix_loc} } : $self->form->localize( $second->{prefix_loc} ); } @second_prefix = map { [ '', $_ ] } @second_prefix; my @seconds = $self->_build_number_list( 0, 59, $second->{interval} ); my $element = $self->element( { type => 'Select', name => $second_name, options => [ @second_prefix, map { [ $_, $_ ] } map { sprintf '%02d', $_ } @seconds ], attributes => $second->{attributes}, defined $second->{default} ? ( default => sprintf '%02d', $second->{default} ) : (), } ); apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); return; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::DateTime - Date / Time combo field =head1 SYNOPSIS --- elements: - type: DateTime name: start_datetime label: 'Start:' auto_inflate: 1 =head1 DESCRIPTION Sub-class of L, providing extra C and C Select menus. =head1 METHODS =head2 hour Arguments: \%setting Set values effecting the C select menu. Known keys are: =head3 name Override the auto-generated name of the select menu. =head3 default Set the default value of the select menu =head3 prefix Arguments: $value Arguments: \@values A string or arrayref of strings to be inserted into the start of the select menu. Each value is only used as the label for a select item - the value for each of these items is always the empty string C<''>. =head3 prefix_loc Arguments: $localization_key Arguments: \@localization_keys A localized string or arrayref of localized strings to be inserted into the start of the select menu. Each value is localized and then only used as the label for a select item - the value for each of these items is always the empty string C<''>. Use C insted of C. =head2 minute Arguments: \%setting Set values effecting the C select menu. Known keys are: =head3 name Override the auto-generated name of the select menu. =head3 default Set the default value of the select menu =head3 prefix Arguments: $value Arguments: \@values A string or arrayref of strings to be inserted into the start of the select menu. Each value is only used as the label for a select item - the value for each of these items is always the empty string C<''>. =head3 prefix_loc Arguments: $localization_key Arguments: \@localization_keys A localized string or arrayref of localized strings to be inserted into the start of the select menu. Each value is localized and then only used as the label for a select item - the value for each of these items is always the empty string C<''>. Use C insted of C. =head2 second Arguments: \%setting Set values effecting the C select menu. Known keys are: =head3 name Override the auto-generated name of the select menu. =head3 default Set the default value of the select menu =head3 prefix Arguments: $value Arguments: \@values A string or arrayref of strings to be inserted into the start of the select menu. Each value is only used as the label for a select item - the value for each of these items is always the empty string C<''>. =head3 prefix_loc Arguments: $localization_key Arguments: \@localization_keys A localized string or arrayref of localized strings to be inserted into the start of the select menu. Each value is localized and then only used as the label for a select item - the value for each of these items is always the empty string C<''>. Use C insted of C. =head2 field_order Arguments: \@fields Default Value: ['day', 'month', 'year', 'hour', 'minute'] Specify the order of the date fields in the rendered HTML. If you want the L selector to display, you must set both C and L yourself. Eg: elements: type: DateTime name: foo strftime: '%d-%m-%Y %H:%M:%S' field_order: ['day', 'month', 'year', 'hour', 'minute', 'second'] Not all fields are required. No single field can be used more than once. =head1 CAVEATS See L =head1 SEE ALSO Is a sub-class of, and inherits methods from L L, L, L, L L =head1 AUTHOR Carl Franks, C =head1 LICENSE This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Checkbox.pm100644001751001752 502412331714662 20700 0ustar00carlcarl000000000000HTML-FormFu-2.01/lib/HTML/FormFu/Elementpackage HTML::FormFu::Element::Checkbox; $HTML::FormFu::Element::Checkbox::VERSION = '2.01'; use Moose; extends 'HTML::FormFu::Element'; with 'HTML::FormFu::Role::Element::Input'; use HTML::FormFu::Constants qw( $EMPTY_STR ); __PACKAGE__->mk_output_accessors(qw( default )); after BUILD => sub { my ( $self, $args ) = @_; $self->field_type('checkbox'); $self->value(1); $self->multi_layout( [ 'field', 'label', ] ); return; }; sub process_value { my ( $self, $input ) = @_; # ignore submitted input return $self->value; } sub prepare_attrs { my ( $self, $render ) = @_; my $form = $self->form; my $submitted = $form->submitted; my $default = $self->default; my $original = $self->value; my $value = defined $self->name ? $self->get_nested_hash_value( $form->input, $self->nested_name ) : undef; if (defined $value and ref $value eq 'ARRAY') { $value = $original if grep { $_ eq $original } @$value; } if ( $submitted && defined $value && defined $original && $value eq $original ) { $render->{attributes}{checked} = 'checked'; } elsif ($submitted && $self->retain_default && ( !defined $value || $value eq $EMPTY_STR ) ) { $render->{attributes}{checked} = 'checked'; } elsif ($submitted) { delete $render->{attributes}{checked}; } elsif ( defined $default && defined $original && $default eq $original ) { $render->{attributes}{checked} = 'checked'; } $self->SUPER::prepare_attrs($render); return; } __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME HTML::FormFu::Element::Checkbox - Checkbox form field =head1 SYNOPSIS my $e = $form->element( Checkbox => 'foo' ); =head1 DESCRIPTION Checkbox form field. =head1 METHODS =head2 value Default Value: 1 =head2 default_empty_value Inherited. See L for details. =head2 multi_layout Overrides the default value of L to swap the C and C