Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub render_field {
- my ($self, $fieldname) = @_;
- my $field = $self->form->field($fieldname);
- ## figure out what field template we need to load based on the field
- my @templates_to_try = (
- $self->form->name . '/' . $fieldname,
- $self->form->name . '/' . $field->field_type,
- $fieldname,
- $field->field_type
- );
- ## Order for trying templates should be:
- ## formname/fieldname
- ## formname/fieldtype
- ## fieldname
- ## fieldtype
- ## --jk need to set up $vars and such.
- my $output;
- my $vars = {};
- my $template_found = 0;
- foreach my $template_name (@templates_to_try) {
- my $res = $self->template->process($template_name, $vars, \$output);
- if ($res) {
- $template_found = 1;
- last;
- }
- }
- if (!$template_found) {
- ## crap. throw an error or something, we couldn't find ANY matching template.
- croak "Unable to find any template for " . $self->form->name . ':' . $field->name . " tried: " . join(", ", @templates_to_try);
- }
- return $output;
- }
Add Comment
Please, Sign In to add comment