Embperl

 view release on metacpan or  search on metacpan

Embperl/Form.pm  view on Meta::CPAN

use Embperl ;
use Embperl::Form::Control ;
use Embperl::Form::Validate ;
use Embperl::Form::Control::blank ;

use Embperl::Inline ;

use Data::Dumper ;
use Storable ;
use MIME::Base64 ;
use Scalar::Util qw{weaken} ;

our %forms ;
our $form_cnt = 1 ;
our %CLEANUP = ('forms' => 0) ;

use vars qw{$epreq} ;

# ---------------------------------------------------------------------------
#
#   sub_new - create a new sub form

Embperl/Form.pm  view on Meta::CPAN

    $self -> {jsnamespace}   .= '.' if ($self -> {jsnamespace}) ;
    $self -> {disable}        = $options -> {disable} ;
    $self -> {control_packages} = $options -> {control_packages} ;
    $self -> {datasrc_packages} = $options -> {datasrc_packages} ;
    $self -> {formptr}          = ($options -> {formptr} || "$self") . '/' . $id  ;
    bless $self, $class if (!ref $class);

    # The following lines needs to there twice!
    # some weired bug in Perl?
    $Embperl::FormData::forms{$self -> {formptr}} = $self ;
    weaken($Embperl::FormData::forms{$self -> {formptr}});
    #$Embperl::FormData::forms{$self -> {formptr}} = $self ;

    if ($toplevel)
        {
        $self -> {fields2empty} = [] ;
        $self -> {init_data}    = [] ;
        $self -> {init_markup}  = [] ;
        $self -> {prepare_fdat} = [] ;
        $self -> {code_refs}    = [] ;
        $self -> {constrain_attrs} = [] ;

Embperl/Form.pm  view on Meta::CPAN

        $self -> {init_markup}  = $self -> parent_form -> {init_markup} ;
        $self -> {prepare_fdat} = $self -> parent_form -> {prepare_fdat} ;
        $self -> {constrain_attrs}    = $self -> parent_form -> {constrain_attrs} ;
        $self -> {code_refs}    = $self -> parent_form -> {code_refs} ;
        $self -> {do_validate}  = $self -> parent_form -> {do_validate} ;
        $self -> {all_controls} = $self -> parent_form -> {all_controls} ;
        }
    if ($self -> has_code_refs)
        {
        push @{$self -> {code_refs}}, $self  ;
        weaken ($self -> {code_refs}[-1]) ;
        }
    $self -> new_controls ($controls, $options, undef, $id, $options -> {masks}, $options -> {defaults}) ;

    $self -> {noframe} = 1 if ($controls && @$controls > 0 &&
                               $controls -> [0] -> noframe) ;


    return $self ;
    }

Embperl/Form.pm  view on Meta::CPAN


        if (ref $control eq 'HASH')
            {
            my $type = $control -> {type}  ;
            $control = $self -> new_object ($packages, $type, $control) ;
            if (!$no_init)
                {
                if ($control -> can ('init_data'))
                    {
                    push @{$self -> {init_data}}, $control ;
                    weaken ($self -> {init_data}[-1]) ;
                    }
                if ($control -> can ('init_markup'))
                    {
                    push @{$self -> {init_markup}}, $control ;
                    weaken ($self -> {init_markup}[-1]) ;
                    }
                if ($control -> can ('prepare_fdat'))
                    {
                    push @{$self -> {prepare_fdat}}, $control ;
                    weaken ($self -> {prepare_fdat}[-1]) ;
                    }
                if ($control -> has_code_refs)
                    {
                    push @{$self -> {code_refs}}, $control ;
                    weaken ($self -> {code_refs}[-1]) ;
                    }
                if ($control -> has_validate_rules)
                    {
                    push @{$self -> {do_validate}}, $control ;
                    weaken ($self -> {do_validate}[-1]) ;
                    }
                push @{$self -> {constrain_attrs}}, $control -> constrain_attrs ;
                $self -> {all_controls}{$name} = $control ;
                weaken ($self -> {all_controls}{$name}) ;
                }
            }
        $self -> {controlids}{$control->{id}} = $control ;

        next if ($control -> is_disabled ()) ;
        if ($control -> {sublines})
            {
            my $i = 0 ;
            my $name = $control -> {name} ;
            foreach my $subcontrols (@{$control -> {sublines}})

Embperl/Form.pm  view on Meta::CPAN

                while (exists $self -> {controlids}{$ctlid})
                    {
                    $ctlid = $control->{name} . '_' . $q ;
                    $q++ ;
                    }
                my $class = ref $self ;
                local $options -> {disable} = $control -> {disables}[$i] ;
                my $subform = $class -> sub_new ($subcontrols, $options, $ctlid, 0, $self -> {formptr}) ;
                $subform -> {text} ||= $control -> {options}[$i] if (exists ($control -> {options}) && $control -> {options}[$i]) ;
                $subform -> {parent_control} = $control ;
                weaken ($subform -> {parent_control}) ;
                push @ids, $ctlid ;
                push @obj, $subform ;
                $i++ ;
                }
            $control -> {subobjects} = \@obj ;
            $control -> {subids}     = \@ids ;
            }
        $n++ ;
        }
    }



( run in 0.241 second using v1.01-cache-2.11-cpan-65fba6d93b7 )