initial package
OBS-URL: https://build.opensuse.org/package/show/devel:languages:perl/perl-Catalyst-Controller-FormBuilder?expand=0&rev=1
This commit is contained in:
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.osc
|
3
Catalyst-Controller-FormBuilder-0.06.tar.gz
Normal file
3
Catalyst-Controller-FormBuilder-0.06.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:78484f2759216a9fc705461201edc763a0b4179bdf30c9036f1e4d774923319a
|
||||
size 35669
|
6
perl-Catalyst-Controller-FormBuilder.changes
Normal file
6
perl-Catalyst-Controller-FormBuilder.changes
Normal file
@@ -0,0 +1,6 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 14 07:50:37 UTC 2011 - coolo@opensuse.org
|
||||
|
||||
- initial package 0.06
|
||||
* created by cpanspec 1.78.04
|
||||
|
189
perl-Catalyst-Controller-FormBuilder.spec
Normal file
189
perl-Catalyst-Controller-FormBuilder.spec
Normal file
@@ -0,0 +1,189 @@
|
||||
#
|
||||
# spec file for package perl-Catalyst-Controller-FormBuilder (Version 0.06)
|
||||
#
|
||||
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
Name: perl-Catalyst-Controller-FormBuilder
|
||||
Version: 0.06
|
||||
Release: 1
|
||||
License: CHECK(GPL+ or Artistic)
|
||||
%define cpan_name Catalyst-Controller-FormBuilder
|
||||
Summary: Catalyst FormBuilder Base Controller
|
||||
Url: http://search.cpan.org/dist/Catalyst-Controller-FormBuilder/
|
||||
Group: Development/Libraries/Perl
|
||||
Source: http://www.cpan.org/authors/id/M/MS/MSTROUT/%{cpan_name}-%{version}.tar.gz
|
||||
BuildArch: noarch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: perl
|
||||
BuildRequires: perl-macros
|
||||
BuildRequires: perl(Catalyst::Runtime) >= 5.7
|
||||
BuildRequires: perl(CGI::FormBuilder) >= 3.02
|
||||
BuildRequires: perl(Class::Data::Inheritable) >= 0.04
|
||||
BuildRequires: perl(Class::Inspector) >= 1.13
|
||||
BuildRequires: perl(ExtUtils::MakeMaker)
|
||||
BuildRequires: perl(MRO::Compat) >= 0.09
|
||||
BuildRequires: perl(Scalar::Util) >= 1.19
|
||||
BuildRequires: perl(Test::WWW::Mechanize::Catalyst) >= 0.37
|
||||
BuildRequires: perl(Tie::IxHash) >= 1.21
|
||||
Requires: perl(Catalyst::Runtime) >= 5.7
|
||||
Requires: perl(CGI::FormBuilder) >= 3.02
|
||||
Requires: perl(Class::Data::Inheritable) >= 0.04
|
||||
Requires: perl(Class::Inspector) >= 1.13
|
||||
Requires: perl(MRO::Compat) >= 0.09
|
||||
Requires: perl(Scalar::Util) >= 1.19
|
||||
Requires: perl(Test::WWW::Mechanize::Catalyst) >= 0.37
|
||||
Requires: perl(Tie::IxHash) >= 1.21
|
||||
Recommends: perl(Catalyst::View::TT)
|
||||
%{perl_requires}
|
||||
|
||||
%description
|
||||
This base controller merges the functionality of *CGI::FormBuilder* with
|
||||
Catalyst and the following templating systems: Template Toolkit, Mason and
|
||||
HTML::Template. This gives you access to all of FormBuilder's niceties,
|
||||
such as controllablefield stickiness, multilingual support, and Javascript
|
||||
generation. For more details, see the CGI::FormBuilder manpage or the
|
||||
website at:
|
||||
|
||||
http://www.formbuilder.org
|
||||
|
||||
FormBuilder usage within Catalyst is straightforward. Since Catalyst
|
||||
handles page rendering, you don't call FormBuilder's 'render()' method, as
|
||||
you would normally. Instead, you simply add a ':Form' attribute to each
|
||||
method that you want to associate with a form. This will give you access to
|
||||
a FormBuilder '$self->formbuilder' object within that controller method:
|
||||
|
||||
# An editing screen for books
|
||||
sub edit : Local Form {
|
||||
my ( $self, $c ) = @_;
|
||||
$self->formbuilder->method('post'); # set form method
|
||||
}
|
||||
|
||||
The out-of-the-box setup is to look for a form configuration file that
|
||||
follows the the CGI::FormBuilder::Source::File manpage format (essentially
|
||||
YAML), named for the current action url. So, if you were serving
|
||||
'/books/edit', this plugin would look for:
|
||||
|
||||
root/forms/books/edit.fb
|
||||
|
||||
(The path is configurable.) If no source file is found, then it is assumed
|
||||
you'll be setting up your fields manually. In your controller, you will
|
||||
have to use the '$self->formbuilder' object to create your fields,
|
||||
validation, and so on.
|
||||
|
||||
Here is an example 'edit.fb' file:
|
||||
|
||||
# Form config file root/forms/books/edit.fb
|
||||
name: books_edit
|
||||
method: post
|
||||
fields:
|
||||
title:
|
||||
label: Book Title
|
||||
type: text
|
||||
size: 40
|
||||
required: 1
|
||||
author:
|
||||
label: Author's Name
|
||||
type: text
|
||||
size: 80
|
||||
validate: NAME
|
||||
required: 1
|
||||
isbn:
|
||||
label: ISBN#
|
||||
type: text
|
||||
size: 20
|
||||
validate: /^(\d{10}|\d{13})$/
|
||||
required: 1
|
||||
desc:
|
||||
label: Description
|
||||
type: textarea
|
||||
cols: 80
|
||||
rows: 5
|
||||
|
||||
submit: Save New Book
|
||||
|
||||
This will automatically create a complete form for you, using the specified
|
||||
fields. Note that the 'root/forms' path is configurable; this path is used
|
||||
by default to integrate with the 'TTSite' helper.
|
||||
|
||||
Within your controller, you can call any method that you would on a normal
|
||||
'CGI::FormBuilder' object on the '$self->formbuilder' object. To manipulate
|
||||
the field named 'desc', simply call the 'field()' method:
|
||||
|
||||
# Change our desc field dynamically
|
||||
$self->formbuilder->field(
|
||||
name => 'desc',
|
||||
label => 'Book Description',
|
||||
required => 1
|
||||
);
|
||||
|
||||
To populate field options for 'country', you might use something like this
|
||||
to iterate through the database:
|
||||
|
||||
$self->formbuilder->field(
|
||||
name => 'country',
|
||||
options =>
|
||||
[ map { [ $_->id, $_->name ] } $c->model('MyApp::Country')->all ],
|
||||
other => 1, # create "Other:" box
|
||||
);
|
||||
|
||||
This would create a select list with the last element as "Other:" to allow
|
||||
the addition of more countries. See the CGI::FormBuilder manpage for
|
||||
methods available to the form object.
|
||||
|
||||
The FormBuilder methodolody is to handle both rendering and validation of
|
||||
the form. As such, the form will "loop back" onto the same controller
|
||||
method. Within your controller, you would then use the standard FormBuilder
|
||||
submit/validate check:
|
||||
|
||||
if ( $self->formbuilder->submitted && $self->formbuilder->validate ) {
|
||||
$c->forward('/books/save');
|
||||
}
|
||||
|
||||
This would forward to '/books/save' if the form was submitted and passed
|
||||
field validation. Otherwise, it would automatically re-render the form with
|
||||
invalid fields highlighted, leaving the database unchanged.
|
||||
|
||||
To render the form in your tt2 template for example, you can use 'render'
|
||||
to get a default table-based form:
|
||||
|
||||
<!-- root/src/books/edit.tt -->
|
||||
[% FormBuilder.render %]
|
||||
|
||||
You can also get fine-tuned control over your form layout from within your
|
||||
template.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{cpan_name}-%{version}
|
||||
|
||||
%build
|
||||
%{__perl} Makefile.PL INSTALLDIRS=vendor
|
||||
%{__make} %{?_smp_mflags}
|
||||
|
||||
%check
|
||||
%{__make} test
|
||||
|
||||
%install
|
||||
%perl_make_install
|
||||
%perl_process_packlist
|
||||
%perl_gen_filelist
|
||||
|
||||
%clean
|
||||
%{__rm} -rf %{buildroot}
|
||||
|
||||
%files -f %{name}.files
|
||||
%defattr(-,root,root,755)
|
||||
%doc %attr(644,-,-) Changes
|
||||
|
||||
%changelog
|
Reference in New Issue
Block a user